Search code examples
reactjs12factor

ReactJS and 12 factor apps


My workplace has recently switched to developing 12 factor apps. Along with this we have been encouraged to adopt new tools and techniques. I'm trying to choose the view engine for a dynamic frontend. I'm contemplating ReactJS. However, as I'm fairly green, I'm concerned using ReactJS state breaks the stateless requirement of 12 factor apps?


Solution

  • React state refers to components, components hold the state they need to draw themselves. Keep in mind that the render method of a component needs to be able to draw it at any point, and for that it needs to know the current state of the component. A good example is a input field, a component that holds one input field needs to hold the value of that input field as current state to be able to redraw the field at any point of time.

    Another common topics in react apps is application state kept in stores, however this is not what you would think as well. This refers to the state of all the components in the application, and is usually gathered/formed and changed from 2 sources, either responses from the server, or user interaction with components. Keep in mind that this state is meant to persist for one session, and it doesn't make the application stateful.

    In summary I would say it is quite safe to use React to build a 12 factor app, we are using React to do the same for a cloud based ERP system, and so far it is going great!