fgerschau / comments

1 stars 0 forks source link

useref-react-hooks/ #13

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

How to use React's useRef() hook

Learn how to use the useRef hook to get the most out of React's functional components.

https://felixgerschau.com/useref-react-hooks/

dennis-8 commented 3 years ago

Hi,

nice article. Can you please write a guide about custom hooks? How to write/use them?

Dennis

fgerschau commented 3 years ago

@denis-n thanks for the feedback! It sounds like an interesting topic, I'll add it to my list and try to work on it soon :)

Sebarbossus commented 2 years ago

I felt confused when reading other articles about what "useRef()" does exactly but after reading this, I can surely say I've finally understood the topic!

fgerschau commented 2 years ago

@Sebarbossus thanks! It makes me happy to hear that :smile:

fgerschau commented 2 years ago

@dennis-8 I finally wrote an article about custom hooks and how I use them to make my code look cleaner. Maybe you want to check that out :smile:

ZhaoTim commented 2 years ago

We can give the class component instance ref attribute like this:

class Demo extends React.Component{}

const App = () => {
  const ref = useRef();
  return <Demo ref={ref} />
}

Not sure why you didn't mention