mthanh2209 / react-training

https://react-training-eight.vercel.app
0 stars 0 forks source link

Implement manipulating dom with refs #156 #179

Closed mthanh2209 closed 10 months ago

mthanh2209 commented 10 months ago
  1. How to access a DOM node managed by React with the ref attribute
    • In React, you can use the ref attribute to create a reference to a React element or component.
    • This allows you to directly access and manipulate the DOM node associated with that element or component.
  2. How the ref JSX attribute relates to the useRef Hook
    • The ref JSX attribute and the useRef Hook are related concepts in React.
    • In class components, you use the ref attribute to create a reference and later access the DOM node.
  3. How to access another component’s DOM node
    • To access another component's DOM node, you can use a callback function with the ref attribute.
  4. In which cases it’s safe to modify the DOM managed by React
    • Avoid direct DOM manipulation outside of React's control in the initial render (render method), as it can lead to unexpected behavior.
    • It's recommended to use React's state and props to manage the component's behavior, and only access the DOM directly when necessary.
vercel[bot] commented 10 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
react-training ❌ Failed (Inspect) Jan 16, 2024 9:59am
storybook ❌ Failed (Inspect) Jan 16, 2024 9:59am