Open utterances-bot opened 3 years ago
Hi,
nice article. Can you please write a guide about custom hooks? How to write/use them?
Dennis
@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 :)
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!
@Sebarbossus thanks! It makes me happy to hear that :smile:
@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:
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
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/