3 ms·
My experience is mixed but mostly positive. - Agreed about useState (and useReducer). They’re simple and they get the job done. - Agreed about useCallback as
by jakelazaroff 5y ago
My experience is mixed but mostly positive.
- Agreed about useState (and useReducer). They’re simple and they get the job done.
- Agreed about useCallback as well, it’s a lot of boilerplate.
- State in general is a hard problem to deal with, but I’m not sure how hooks in particular encourage it? Class components had the same issue.
- IMO, useEffect is a huge footgun. I understand how it works, I understand how closures work, but it is by far the biggest source of hook-related bugs I’ve experienced.
- This eslint plug-in will solve your dependency list woes: https://www.npmjs.com/package/eslint-plugin-react-hooks https://www.npmjs.com/package/eslint-plugin-react-hooks
- ketzo 5y ago+1 for that eslint plugin, I was just idly wondering if something like that existed earlier this week. Thanks.
- jakelazaroff 5y agoUnless your app is peculiar in some way I’d recommend using something like Create React App, which includes it automatically. https://create-react-app.dev https://create-react-app.dev