Published 7/20/2016
Future in React

React

Currently I have been working mostly as FrontEnd SPA developer so I would like to share some thoughts about this interesting topic.

I would like to periodically update and add there some hints, which may find someone usefull.

Preferred (my) technologies and frameworks:

  • React as UI library
    • with React Router
    • and React Native for native android/iOS apps
  • Redux as application state
    • with Redux Saga for side effects
  • CSS Modules, PostCSS instead of sass/less

Unit testing of React application:

  • Mocha - test framework running on Node.js
  • Chai - assertions library
  • Enzyme - makes it easier to assert, manipulate, and traverse components
  • Sinon - mocking - stub and spy functionality

ES6 React Class: Constructor vs componentWillReceiveProps

It's simple to get lost with component state when we are mixing it with properties. We need to make sure state is always updated with passed properties.

There are important differences need to know when working with component constructor and componentWillReceiveProps:

  • constructor is called only when component is placed on screen (started rendering)
  • with constructor we may set only initial state
  • componentWillReceiveProps is called always when props passed from outside
  • with componentWillReceiveProps we can updated state by information from new props

Stateless components (with Redux)

Use stateless components when using Redux. Try to avoid containing local state in components - do it only in edge cases, eg. some internal styling or state which may not be needed outside (in other components) in any circumstances in future.

(article is still in edit, last quick update 2017 march)