简体   繁体   中英

Does React.js have a basic Flux implementation?

I am new to React.js and I am enjoying it a lot. I came across the Flux architecture while reading the React.js documentation. I understand that Flux is just a pattern and that there are many Flux implementations out there – including Facebook's own. I also know that React.js can be used without any Flux implementation.

My question is: is it safe to say that React.js has its own (small) Flux implementation embedded within it? In my opinion, I don't see any other way for React.js to achieve its uni-directional data-flow without having its own Flux implementation – which is, of course, replaceable with other Flux implementations.

Flux is pattern for handling application state and React is just view library. You don't have to use Flux with React , but it's preferred way.

Most popular Flux implementation seem to be Redux nowadays.

The picture below is an explanation of what is, and what is not in react:

  • The green stuff = part of React: a library to render a component tree in a DOM (or somewhere else).
  • Unidirectional flow means that react is made for/ allows only top-down updates: any component can render/ update/ change itself (through change in state) or its children (through passing props down the tree).
  • The blue parts are part of the Flux-pattern. React does not have any code/ library components for this.

在此输入图像描述

The elements of flux make the circle complete: they allow react components to trigger actions, which in turn update stores, and can allow for (top) components to re-render based on changes in stores. There are libraries (ed redux, reflux, alt) that implement the various elements of the flux architecture.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM