Sunday, November 26, 2017

BEST PRACTICES IN REACT JAVASCRIPT

BEST PRACTICES IN REACT JAVASCRIPT
In this discourse, i will list React best practices, methods, and know how's that will help us remain consistent during the app development

     Image result for react javascript

    states

    The state should be avoided as much as possible. It is a good practice to centralize the state and pass it down the component tree as props. Whenever we have a group of components that need the same data, we should set a container element around them that will hold the state. Flux pattern is a nice way of handling the state in React apps.

          proptypes

  •  The PropTypes should always be defined. This will help is track all props in the app and it will also be useful for any developer working on the same project.
  • render
  • − Most of the app's logic should be moved inside the render method. We should try to minimize logic in component lifecycle methods and move that logic in the render method. The less state and props we use, the cleaner the code will be. We should always make the state as simple as possible. If we need to calculate something from the state or props, we can do it inside the render method.
  • Composition

Continue reading