React Today and Tomorrow and 90% Cleaner React With Hooks
Video Statistics and Information
Channel: React Conf
Views: 1,097,455
Rating: undefined out of 5
Keywords:
Id: dpw9EHDh2bM
Channel Id: undefined
Length: 95min 29sec (5729 seconds)
Published: Fri Oct 26 2018
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
React 16.7 alpha is live. yarn add react@next react-dom@next
Hooks docs: https://reactjs.org/docs/hooks-intro.html
Hooks RFC: https://github.com/reactjs/rfcs/pull/68
Hooks PR: https://github.com/facebook/react/pull/13968
Try hooks in codesandbox: https://codesandbox.io/s/kmm79lzm3v
I'm really glad that this is 1 single video.
So is everyone just going to put their production apps on react@next now? I'm tempted
I like the ease of use and composability, I don't like that init code and render code is in the same function which lead to these weird coding constraints (an alternative is possible: https://github.com/reactjs/rfcs/pull/68#issuecomment-433624505).
Another thing to note here is that if they don't bring a compatible API to the class system (and I see no technical reason for not doing so), it's as good as saying classes are deprecated because hooks are a lot more convenient.
It's so awesome! I released a global state library that utilises hooks and it just made it all so clean and easy. β€οΈ
https://github.com/ctrlplusb/easy-peasy
It looks awesome but I really dislike those ordered-based hooks. It seems to only affect
useState
however. Why not giving them names?I've been working with react for 3 years now. ELI5 react hooks
edit: it seems react seems to warn about using useState conditionally, which is somewhat nice
Quick rant: Hooks are super weird.
The two examples below look very similar, but do something completely different, only based on where you put the
useState
functions.Works like expected:
Move
useState
inwards, boom, completely broken:They use global functions to hook into context dependent state almost like the Haskell state monad, but without being explicit in the types or giving any guarantees or predictability. From the one function
Counter2
it's relatively clear how to 'fix' the issue. But what if you blindly factor out theFoo
and theBar
part out to different functions? Because a lack of proper identity (you don't bind it to a lexical name within your programming language)useState
doesn't seem to compose well.Maybe that's intended? Don't really like it so far.
What do they use to present the code with live preview on the side? It looks very slick.