by janci · 10y ago · 0 comments
React components will then boil down to pure render functions. React will then be replaced by simpler VirtualDOM implementation. JS function declaration boilerplate will be removed from render functions, so they will be more HTML with some JS as the other way around. Also they will be called templates.
We are getting back to good-old-days PHP-style webcoding, but with few HUGE improvements.
1. no globals, mostly pure functions
2. no business logic in templates, but in easy-to-reason-about redux-style state reducers
3. client-side rendering / isomorphic apps possible
You won’t find any place in React docs that claims internal state is harmful. There are some guides claiming that but this is not the official position (and I say this as author of Redux and a member of React team). We use state a lot at Facebook, and it’s a large part of what makes React useful.
>next thing will be the lifecycle methods.
Lifecycle methods are also fine. Sure, it’s best when there aren’t too many and they don’t do too much, but it’s a supported feature for a reason. It is occasionally super useful. They aren’t going away.
>React components will then boil down to pure render functions. React will then be replaced by simpler VirtualDOM implementation.
This is an explicit non-goal of React. We think stateful components with lifecycle methods are very useful. If you don’t agree, however, React is indeed not the best choice for you, as it does too much.
I’ve read a lot of misconceptions around React so I plan to put up “Design Goals” document in the repo so people can get a better idea of the direction that we’re moving into, and why.
But it is the first principle of Redux
The state of your whole application is stored in an object tree within a single store.[1]
Am I getting it wrong?
>I plan to put up “Design Goals” document in the repo
That would be great. The "why" is sometimes hard to understand.
[1]http://redux.js.org/docs/introduction/ThreePrinciples.html
>But it is the first principle of Redux
Redux is a very opinionated library and it is not related to React in any way. React does not officially endorse Redux. If (and that’s a big if!) React patterns don’t scale for you or if you personally prefer Redux to them, you can use it, but a Redux app !== a React app.
Which doesn’t mean either of them is the “right” or “wrong” way. Learn React first and try to use it. If you have issues related to state or if you’re just curious, you can also learn Redux to compare their approaches. If you like, you can combine them, or use them separately.
First, thank you for all you do. Huge fan, and you're an asset to the community.
One question I have is around this quote:
> Learn React first and try to use it. If you have issues related to state or if you’re just curious, you can also learn Redux to compare their approaches.
I tried to go down this route with a new employee who I've positioned on a React project (mostly as means of exploration + learning in between other projects)
But as soon as I had to deal with fetching data from the server and pushing it back, I felt the need to jump into Redux. Yes, I could manage this in React, but as soon as I had two "pages" in my app, I feel it would become unwieldily note to use the Redux + Redux-Think (or Sagas) combo.
Am I wrong here, or am I just "comfortable" with Redux, and thus, not persuing the idea of trying to build a more featured app in pure React?
This buzz phrase "easy to reason about" is so popular in the React world. I feel like I'm the only one who finds it oxymoronic. Especially with regard to Redux, which I think is anything but.
Angular 1/2, Ember, Backbone are all pretty "easy to reason about", so much so that it is rarely pointed out.
Well said.
"In an ideal world, most of your components would be stateless functions because in the future we’ll also be able to make performance optimizations specific to these components by avoiding unnecessary checks and memory allocations. This is the recommended pattern, when possible."
See https://facebook.github.io/react/docs/reusable-components.ht...
However, state is something on the whole that's required more often higher than lower in your architecture.
I'm pretty sure that's what they're talking about here. Hope that helps.
On this note, I find that I rarely use state in child components, because as much as possible I have functions that compute values off props and simply return that where I need them, rather than storing them as state variables.
[1] https://facebook.github.io/react/docs/thinking-in-react.html