9 Things for Beginner About ReactJS
It’s just a view library: React is not another MVC framework, or any other kind of framework. It’s just a library for rendering your views.
Keep your components small: Every good developer knows that small classes/modules/whatever are easier to understand, test, and maintain, and the same is true of React components. My mistake when starting out with React was under-estimating just how small my components should be.
Write functional components
Write stateless components: Just be very conscious of every time you add state to a component. Once you start, it can become very easy to add ‘just one more thing’, and things get out of control before you know it!
Use Redux.js: The API is smaller, simpler, and better-documented. I’ve found it much quicker and easier to learn all of the concepts, and therefore much easier to understand the flow of actions and information in my own projects.
Always use propTypes: When in development (not production), if any component is not given a required prop, or is given the wrong type for one of its props, then React will log an error to let you know.
Use shallow rendering: Shallow rendering is nice, because it allows you to render a single component completely, but without delving into any of its child components to render those. Instead, the resulting object will tell you things like the type and props of the children. This gives us good isolation, allowing testing of a single component at a time.
Use the React and Redux dev tools: Speaking of tooling, the development tools for React and Redux are pretty awesome. You can also set up hot module replacement with webpack, so that your page updates as soon as you save your code — no browser refresh required.