Support React 16.8.0 aka Hooks
complete
Thijs Koerselman
Now that React merged the Hooks feature it will soon be released. The API is such a nice enhancement for structuring code that I can't wait to start using it.
Besides being a nice tool Hooks will also replace recompose and a lot of messy HoC patterns. The latter is particularly relevant when using Typescript, since proper typing is sometimes hard or impossible to achieve. For example typesafe inject for MobX
Brent Vatne
complete
https://blog.expo.io/expo-sdk-v33-0-0-is-now-available-52d1c99dfe4c
Tom Ktorza
Solution who works for me: to verify that your expo -V is 2.18.4^
expo init testHooks
cd testHooks
copy this folder (https://github.com/kevinwolfcr/formal/blob/master/apps/formal-playground-native/scripts) to your root folder project
add "postinstall": "node scripts/enable-rn-hooks.js", to your package.json into scripts object (up to "start" for example)
update react to 16.8.6 into your package.json
yarn install (or npm install)
expo start
Enjoy
tal mikey
Tom Ktorza: didn't work, failed with " undefined postinstall:
node scripts/enable-rn-hooks.js
",please add git repo for the example
Tom Ktorza
tal mikey: updated my post, your postinstall script have to be into scripts object, it's here?
tal mikey
Tom Ktorza: yes, it's. It says that postinstall is undefined.
Tom Ktorza
tal mikey: try to do manually:
delete postinstall line into your package.
yarn install
node scripts/enable-rn-hooks.js
tal mikey
Tom Ktorza: can you upload some photo? git repo will be much appreciated
Tom Ktorza
tal mikey: package.json:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"postinstall": "node scripts/enable-rn-hooks.js",
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject",
"test": "node ./node_modules/jest/bin/jest.js --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/samples": "2.1.1",
"expo": "^32.0.0",
"react": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-navigation": "^3.0.9"
},
"devDependencies": {
"babel-preset-expo": "^5.0.0",
"jest-expo": "^32.0.0"
},
"private": true
}
Gilson Viana
Spent the last 2 hours trying to figure out why I couldn't make Hooks to work on my components, till I found that the feature it's still in progress. Can't wait for the new release.
Max Bush
When is the expected release?
ken
The author of https://github.com/kevinwolfcr/formal found out a way to use Hooks in expo SDK32.
I confirmed it works.
Worth to try if you really want to use, I think.
Most case,
../../node_modules/ => ./node_modules/
Simon Madsen
ken: This is awesome, for windows users just "yarn add react@16.8.6" and copy the folders (fb/oss/shims) manually and delete .expo folder if you have an existing project.
M
Mark Volkmann
ken: Can you provide a bit more detail on how to set this up? It's not clear to me what I'm supposed to do with the file
enable-rn-hooks.js
.Steffen Hageland
Mark Volkmann: You don't really need that file. You just need to do what the file does. Basically it just replaces the renderer included in SDK32 with the renderer from the newest version of react-native (which supports hooks)
Thaer Abbas
Mark Volkmann: Copy the
scripts
folder to the root of your project, make sure to remove ../../
from the cp nodemodules
command as well. Add the postinstall
script in package.json
. Either run npm install/yarn
or npm run postinstall
. Profit 💰Siso Sosi
Thaer Abbas: if this is so easy, why doesnt the expo team provide a new release with just hooks enabled? would be soo worth it
Stuart Casarotto
https://github.com/expo/expo/pull/4030 Just merged.
Nan Montaño
Estimate on the SDK 33 release which includes Hooks:
Lucas Reppe Welander
this really should be prio
y
yang4515
I can't wait to use this feature. I open this page 200 times a day.
Simon Madsen
yang4515: +1
Siso Sosi
yang4515: +1
Brent Vatne
in progress
Jorge Escobar
Brent Vatne: Can't wait... literally I have a client on a holding pattern waiting for this to start! :)
Siso Sosi
Jorge Escobar: me too! :)
Daniel Kehlibarov
Brent Vatne: Amazing! 64-bit apps finally! I get butterflies in my stomach every time a new Expo SDK is expected. :)
Load More
→