Live data from Hacker News

React v16.3.0: New lifecycles and context API

reactjs.org

131–133 of 133 posts

Re: React v16.3.0: New lifecycles and context API

#131
post #91

Earlier quoted context omitted.

Doesn't feel like it's needed. "getStateFromProps" would have been fine. I think any state "derivation" from props is implied.

We intentionally made the naming a little bit obtuse. A name like `getStateFromProps` implies this is a common operation because it sounds so “normal”. And this is, in fact, a common misconception with React beginners who try to copy props into state instead of using props directly or lifting state up. So we wanted the naming to reflect that this pattern is not supposed to be the most common.

This naming choice makes sense now!

Re: React v16.3.0: New lifecycles and context API

#132

Earlier quoted context omitted.

Components are just functions -- HOC's are higher order functions. The pattern dropped out like all patterns drop out -- from use. Its nothing specific to React, but to functional programming

Just replied in the other spot -- I understand the similarities now, but I think this points to react still not being as simple as it could be -- if components were really as simple as being functions from state to UI, reacts API would be drastically smaller. My point is that it's not that simple (for better or for worse, some of the added complexity in the API IS essential IMO), but people still say things like "com…

It just seems like your misunderstandings are preventing you from understanding React properly, and that those misunderstandings could be rectified by more experience with the library. Learning is inherently difficult but sometimes its best to trust in the process and dive in :)

Re: React v16.3.0: New lifecycles and context API

#133

Earlier quoted context omitted.

For different reasons I don't use Redux that much in my app. The state is persisted in the url, or to be more precise React-Router's location. So let's say I have five different components on the page. All of them receive location and history as props. Each component updates the url separately, let's say a table updates the url with sort1=blah now the component needs to read this param compare next and current and fe…

I believe it's in the blog post: https://reactjs.org/blog/2018/03/27/update-on-async-renderin... (TLDR: Use `componentDidUpdate` for this.) Have you had a chance to skim through it?

Yes, I also saw your post on twitter. I will try to use it from now on. Thanks!
Post reply on HN