4 ms·
You shouldn't pass properties to setState. That's a very non-reactive kind of thing. Just use the properties directly. They should be immutable.
by bayesian_horse 4y ago
You shouldn't pass properties to setState. That's a very non-reactive kind of thing. Just use the properties directly. They should be immutable.
- recursive 4y agoI confused state and props. The distinction between the two has always been a bit hazy to me. I'm not sure what "non-reactive" means.
- bayesian_horse 4y agoA React component is supposed to be a pure function, a mapping from props+context as input into an output which is a React element plus sideeffects (which when executed by the React library will often change the context). State lives in the context. To illustrate statefulness: If you drop a flummy ball on the floor, it will bounce back and doesn't change. If you drop an egg, it will change and you can't drop it easily again. The ball is stateless, the egg is stateful.