Hello Dev Community! 👋
Today I will talk about some React tips I want to share with you. Those will be in the form of some tweets that I posted.
Leave a 🧡 & 🦄 if you like this article.
10 Cool React Tips ⚛️
1. Create a Webpack config in a conveniant way using createapp.dev
2. Learn to automatically check Accessibility with Axe
3. Use Parcel for 0 config builds, even with Typescript
4. React testing library debug function
5. How to handle errors in React
There is a cool package created by on of the React core team members for Error boundaries. You can check it out here.
6. Use function components and Hooks ✔️
There are many reasons apart from just this being the trend. If you use function components it is much more probable to find libraries that expose hooks APIs.
Probably in the future a lot of libraries will only expose hooks APIs. You won't be able to use hook APIs with class components.
7. Use the React Context API for shared / global state
Simply put - I am seeing less and less use cases for Redux or other state management libraries considering in React we have the Context API.
With the Context API you are using the same paradigm as with regular
hooks. This is lowering the learning curve for new React developers as they don't need to learn Redux or some other state management library.
8. Distinction in React Testing lib for getBy* vs queryBy*
9. Learn to use React testing library correctly 🚀
Doing this can skyrocket the confidence you have in writing tests and the production code that you write.
10. Correctly handling async await in React components
Learning how to correctly handle asynchronous code in React is difficult and can lead to a bugfest. I explain all the concepts and how to deal with it in a simple way in one of my other dev articles:
👇 Comment below 👇
Let me know if this is valuable for you and share some cool stuff you learned about React lately.