-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to react 16 #191
Upgrade to react 16 #191
Conversation
Oh wow! Thanks so much for this, whole project is modernized :D If I understand correctly:
For those first two points, I wonder if chai-enzyme is worth the trouble. It's certainly a convenience, but I feel like regular Chai is good enough (as I see you've done, by just using For the third point... I initially thought this was an issue of state carrying between tests, but I remembered that @Hypnosphi's great work meant that we are already mounting for every So, i think we need to figure out what the deal is with |
To your first point, correct. Third point seems to be the biggest issue, i agree. I've read through the enzyme migration guide a couple of times now, but i dont see anything that explains why
|
We're looking good now. I'd still like to add a story (and test) for passing fragments and string to flip-move though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wooo!!
Thanks so much for this, and sorry it took me a few days to get to it (In Mountainview this week, working for my job on-site, so it's been hectic).
I had a really small nit, but I'm happy to quickly do that myself in a subsequent commit.
Will test this locally tomorrow just to make sure nothing funky happens, and will publish a release ASAP!
@@ -3,6 +3,8 @@ | |||
.*/node_modules/editions/.* | |||
.*/node_modules/flow-coverage-report/.* | |||
.*/node_modules/preact/.* | |||
.*/node_modules/@storybook/.* | |||
.*/node_modules/radium/.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guessing modern versions of Storybook use Radium?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly, but via react-treebeard
. We use glamorous
for our own components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool! Wasn't aware you were a contributor to Storybook - thanks for your work there :)
package.json
Outdated
"babel": "6.1.18", | ||
"babel-cli": "6.2.0", | ||
"babel-core": "6.2.1", | ||
"@storybook/react": "^3.2.8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we omit the ^
?
I don't really think this even matters anymore, with Yarn/NPM5. But, my inner OCD wants it to be consistent, haha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably also want to upgrade it to 3.2.12, there has been some critical bugfixes
@@ -8,6 +8,7 @@ config.plugins = [ | |||
new webpack.DefinePlugin({ | |||
'process.env.NODE_ENV': JSON.stringify('production'), | |||
}), | |||
new webpack.optimize.ModuleConcatenationPlugin(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, neat! Keen to see the effect this has on bundle size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
package.json
Outdated
@@ -46,29 +46,29 @@ | |||
"web-animations" | |||
], | |||
"peerDependencies": { | |||
"react": "0.13.x || 0.14.x || 15.x.x", | |||
"react-dom": "0.13.x || 0.14.x || 15.x.x" | |||
"react": ">0.13.x <16.x.x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😊
@joshwcomeau try upgrading to the latest version of yarn i guess storybookjs/storybook#1868 (comment) |
@Hypnosphi can you update your review? |
Woooo!!! Psyched to have this ready :D can't thank you enough for your work on this!! |
Released in (Also, sorry for not debugging the yarn issue more thoroughly myself; the issue was indeed using 0.x yarn, upgrading fixed it!) |
This kind of snowballed.
the old version of storybook doesnt work with react16. it was throwing exceptions before, so i just upgraded it to the most recent version.
This meant webpack had to be upgraded, so i've done that as well. The stories are all looking good so far.
The big problem with react 16 is enzyme. I imported the adapter, but chai-enzyme doesnt play nice with enzyme 3 yet.
There is an open PR which solves most of the issues. the others i circumvented by refactoring the assertions a bit. until its merged, you need to build chai-enzyme yourself:
cd node_modules/chai-enzyme
yarn && yarn build
The
setProps()
call doesnt seem to be working the same way in enzyme 3, which made themountAttached
+attachedWrapper.setProps(...)
logic in the tests break. i worked around this by remounting for every test, but this of course makes the old/new position comparisons not work.=================================
Update:
Refactored testing component so it passes its state to flip-move instead of its props. This means we can use
setState(...)
instead ofsetProps(...)
to trigger a transition.I had to make an empty
setState(...)
call after initial mounting because ...well, setState updates in enzyme 3 still appear to be a bit wonky.I also removed chai-enzyme assertions for the time being.