4 ms·
There are a lot of gotchas with these. Don't call in conditionals, branches, loops. Can only be called from function components. Order of invocation matters (
by eric_b 8y ago
There are a lot of gotchas with these. Don't call in conditionals, branches, loops. Can only be called from function components. Order of invocation matters (yeck!)
If the goal is helping developers "fall in to the pit of success" I think classes are a much better option than this.
- nyclowkey 8y agoyep I see nothing wrong with classes, infact I think I'm going to go back to an older build of React. All this suspense, the messy fiber rewrite and all is just screwing up library. LONG LIVE class based component, there was nothing wrong with them. Don't fix it if ain't broke.
- scrollaway 8y agoGood thing then that, as the page says, "There are no plans to remove classes from React.".
- hajile 8y agoIf an older version of react is the goal, maybe infernoJS would be the ticket. It's way more performant than most versions of React while being mostly API compatible (not sure about the most recent react changes).
- lacker 8y agoThere are a lot of gotchas with the object-oriented way of doing these things too. Don't set `this.state` directly, don't forget to keep your side effect logic in `componentWillMount` parallel to your cleanup logic in `componentWillUnmount`, et cetera.
- deleted 8y ago[deleted]
- eric_b 8y agoYep, no doubt. The problem is they aren't getting rid of old foot guns, just adding new ones. And the new way with hooks isn't obviously superior to the old way (debatable to be sure, but with all the constraints hooks are not a broadly applicable solution to many problems). So now you've got two separate but equally powerful guns pointed at your feet. Is that progress? I'm too old to think so.
- k__ 8y agoInl don't understand why they don't use a second parameter to mark the calls.
- ec109685 8y agoIf you don’t put this in conditional, branches or loops, by definition they will always be called in the same order.