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

Replace componentWillReceiveProps with componentDidUpdate in docs and async component #4109

Merged
merged 5 commits into from
Mar 18, 2021

Conversation

manvydasu
Copy link
Contributor

@manvydasu manvydasu commented Jul 4, 2020

partial fix for 4094 (Remove UNSAFE methods from docs).

Other UNSAFE methods are removed with #4313

@changeset-bot
Copy link

changeset-bot bot commented Jul 4, 2020

⚠️ No Changeset found

Latest commit: 6bd0001

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 4, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 6bd0001:

Sandbox Source
react-codesandboxer-example Configuration

@manvydasu manvydasu force-pushed the fix/4094-partial branch 2 times, most recently from fa4e50b to bde4330 Compare July 4, 2020 12:06
@bladey
Copy link
Contributor

bladey commented Jul 6, 2020

Thanks for this PR @manvydasu!

@bladey bladey added pr/bug-fix PRs that are specifically addressing a bug pr/needs-review PRs that need to be reviewed to determine outcome labels Jul 6, 2020
@TrejoCode
Copy link

<3

@jleider
Copy link

jleider commented Aug 5, 2020

Any timeline on getting this merged and releasing a new version? With strict mode on this reports as a console error which winds up polluting the console with library based messaging making it hard to notice actual errors in your app.

@bladey bladey added pr/needs-review PRs that need to be reviewed to determine outcome and removed pr/needs-review PRs that need to be reviewed to determine outcome labels Aug 24, 2020
@xuniaoji
Copy link

Do we have any plan to release a new version to fix this?

@pervezalam83
Copy link

Please update when this PR will be merged. It seems we can not get rid of the "Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code" until this is merged

@brenobaptista
Copy link

This PR would be very useful, please merge it if possible 😄 thanks, guys!

@Methuselah96
Copy link
Collaborator

Methuselah96 commented Nov 14, 2020

I've started a fork of react-select. Feel free to resubmit this PR on the fork and we can get it merged and released.

EDIT: 🎉 I've archived the fork now that we've got some momentum in this repo and Jed is involved again. Sorry for the disturbance!

Copy link
Collaborator

@Methuselah96 Methuselah96 left a comment

Choose a reason for hiding this comment

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

Thanks for this PR! As noted below, the work for Async will probably become redundant soon and the Header modification needs to be changed. Really appreciate your help!

Comment on lines 120 to 124
UNSAFE_componentWillReceiveProps({ location }: HeaderProps) {
componentDidUpdate(prevProps: HeaderProps) {
const valid = ['/', '/home'];
const shouldCollapse = !valid.includes(this.props.location.pathname);
if (location.pathname !== this.props.location.pathname && shouldCollapse) {
const shouldCollapse = !valid.includes(prevProps.location.pathname);

if (prevProps.location.pathname !== this.props.location.pathname && shouldCollapse) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doing this on update means that the first time you click away from the home page, the transition won't work (which is actually true of the status quo as well).

Instead I would suggest that we call this.setState({ contentHeight: this.content.scrollHeight }); immediately in componentDidMount and get rid of toggleCollapse altogether.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I removed toggleCollapse alltogether and removed contentHeight from the state itself. My suggested approach will get rid of one additional re-render after componentDidMount and the functionality remains the same.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Methuselah96 I tested this locally and doesn't seem to impact anything negatively. Any other concerns or can this conversation be resolved?

packages/react-select/src/Async.js Outdated Show resolved Hide resolved
@ebonow
Copy link
Collaborator

ebonow commented Feb 12, 2021

It seems a bit sluggish when transitioning between pages. I ran a profiler and it seems that it is noticable. It could also likely be due to these change being applied against v3 as opposed to v4 (perhaps giving some credit to the performance gains from the lifecycle method replacements from @Methuselah96) , but I'll try these changes against v4 and see if the differences flatten out.
Screen Shot 2021-02-12 at 9 53 02 AM

@manvydasu
Copy link
Contributor Author

@ebonow
Not sure how these changes could increase rendering time of the component/page.
I removed additional re-render and didn't introduce any setStates or anything.
I can rebase this PR on 4.* if that's needed.

@ebonow
Copy link
Collaborator

ebonow commented Feb 12, 2021

I just ran it against v4 and it seems negligible. Could just be an environmental difference between running local dev server against production server.

One of the changes I noticed that would show up if you rebase is that jsx is now instead imported from

import { jsx } from '@emotion/react';

Also, would you be opposed to helping us rid all of the lifecycle method warnings from the current docs?

Looks like a few of these components could use a version bump specifically in react-router.

Screen Shot 2021-02-12 at 11 02 14 AM

Also you will likely want to run the npm changeset command so that we can make sure you are properly acknowledged.

@ebonow
Copy link
Collaborator

ebonow commented Feb 12, 2021

TLDR: Don't worry about the other dependencies...

Putting this here just to document findings...

Did some more research. Other dependencies causing warnings which need to be updated in both the package.json, and docs/package.json:

    "react-helmet": "^6.1.0",
    "react-router-dom": "^5.2.0",

Outside of that are the atlas dependencies, but these also introduce a peer dependency on styled-components:

    "@atlaskit/button": "^15.1.4",
    "@atlaskit/icon": "^21.2.4",
    "@atlaskit/modal-dialog": "^11.2.6",
    "@atlaskit/spinner": "^15.0.6",
    "@atlaskit/tooltip": "^17.1.2",
    "styled-components": "^5.2.1"

Started getting react key errors in the console, and we're replacing the documentation in the near future, so not worth putting more time into it.

@ebonow ebonow added this to the 4.2 milestone Mar 4, 2021
@ebonow ebonow removed the pr/needs-review PRs that need to be reviewed to determine outcome label Mar 5, 2021
@Methuselah96 Methuselah96 removed this from the 4.2 milestone Mar 5, 2021
Updated file with prettier formatting
@ebonow ebonow added this to the 4.3 milestone Mar 8, 2021
@ebonow ebonow added the category/documentation Issues or PRs about documentation or the website itself label Mar 10, 2021
@JedWatson
Copy link
Owner

Thanks for the PR @manvydasu and the help getting this done everyone, merging now 🙂

@JedWatson JedWatson merged commit 41118ca into JedWatson:master Mar 18, 2021
@ebonow ebonow mentioned this pull request Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category/documentation Issues or PRs about documentation or the website itself pr/bug-fix PRs that are specifically addressing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants