Skip to content
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

Remove old UNSAFE_ lifecycle methods #5020

Merged
merged 5 commits into from
Aug 25, 2018

Conversation

mfix22
Copy link

@mfix22 mfix22 commented Aug 23, 2018

I am not sure if this is a valid fix yet, but I was going to let CI run the tests for me. I'll close and look into it if the build fails.

Let me know if this will cause issues, but I don't think it should. The React docs recommends moving componentWillMount logic into the constructor

@timneutkens
Copy link
Member

Are head update reflected in time before rendering when doing this though? I remember @giuseppeg saying it works fine for styled-jsx, so maybe he can weight in 🕵️

Thank you very much for this contribution, helps a lot 😌

@mfix22
Copy link
Author

mfix22 commented Aug 23, 2018

@timneutkens I believe so, since constructor is called before UNSAFE_componentWillMount, but I am also not an expert on Next.js (:

@giuseppeg
Copy link
Contributor

giuseppeg commented Aug 23, 2018

If side effects are synchronous it should be good :)

See vercel/styled-jsx#457 (comment)

@@ -77,9 +76,6 @@ export default function withSideEffect (reduceComponentsToState, handleStateChan
}
}

// Make UNSAFE_ compatible with version of React under 16.3
polyfill(SideEffect)
Copy link
Author

@mfix22 mfix22 Aug 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timneutkens @giuseppeg I see that a couple tests still use UNSAFE_ . . . do you want me to keep react-lifecycles-compat

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests don't need the compat because we run tests on 16.4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So removing it is perfect 👍

@timneutkens
Copy link
Member

I just realized we don't have integration tests for routing with next/head, could you add a few? Otherwise, I'll add them 👍

@mfix22
Copy link
Author

mfix22 commented Aug 24, 2018

@timneutkens I'm not sure if I have time right now so you will probably get it done a lot sooner than me, but I'll try and get to it 👍

@mfix22
Copy link
Author

mfix22 commented Aug 24, 2018

Actually @timneutkens I'm not exactly sure what you mean by:

routing with next/head

It would be helpful to have some clarification on what exactly to test for, and if I should create a new folder or add it to an existing one.

@timneutkens
Copy link
Member

You can extend test/integration/basic there's navigation tests already, what I meant is that we don't have any tests doing client-side routing that changes the <head> using next/head. So the way to go is creating 2 new pages, and then navigate between them and check if the <head> is updated in both instances 🕵️

@timneutkens
Copy link
Member

Thank you very much for adding the test, I've updated it a bit, this is ready to be merged after tests pass 😌

@timneutkens timneutkens merged commit 9532cc1 into vercel:canary Aug 25, 2018
@mfix22
Copy link
Author

mfix22 commented Aug 25, 2018

Thanks Tim 👍

@mfix22 mfix22 deleted the remove-unsafe-methods branch August 25, 2018 18:38
@SBoudrias
Copy link
Contributor

Any chance this broke Head inside dynamic() components? I'm seeing this doesn't work anymore as of 7-canary.3

@timneutkens
Copy link
Member

@SBoudrias could you create a minimal reproduction so that we can add a test for it?

@lock lock bot locked as resolved and limited conversation to collaborators Aug 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants