Answers for "get element ref react"

0

get element ref react

import React, { useEffect, useRef } from "react";

const MyComponent = () => {
  const myContainer = useRef(null);
  
  useEffect(() => {
    console.log("myContainer..", myContainer.current);
  });

  return (
    <>
      <h1>Ref with react</h1>
      <div ref={myContainer}>I can use the DOM with react ref</div>
    </>
  );
};

export default MyComponent;
Posted by: Guest on June-23-2021
3

cre&atRefs react js

const node = this.myRef.current;
Posted by: Guest on June-07-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language