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

fix: refactor code to use getDerivedStateFromProps #735

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix: refactor code to use getDerivedStateFromProps #735

wants to merge 2 commits into from

Conversation

AdrianInsua
Copy link

@AdrianInsua AdrianInsua commented Apr 20, 2020

This pr will fix #624

In order to do this the code is refactored to use static getDerivedStateFromProps. Considering that the method is static i've moved the methods used inside old willReceiveProps out of the class to avoid repeated code (because we can't call this in static methods).

Also i've moved justPressedUpDown justMouseEntered justSelectedSuggestion into state to acces them in the static method.

Finally i've added a new state variable prevSuggestions to emulate prevProps.suggestions behaviour.

The demo page works fine, but i had some problems with prettier script on build process
(but it works ok without it).

I`m not a React developer so please check the code and let me know if something is wrong

Copy link

@FullstackJack FullstackJack left a comment

Choose a reason for hiding this comment

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

LGTM

@TaiWilkin
Copy link

@AdrianInsua Is this still in-progress?

@AdrianInsua
Copy link
Author

@TaiWilkin the PR was done several months ago, but it seems to have conflicts now, as soon as i have some free time i will fix them

@lregla
Copy link

lregla commented Dec 18, 2020

@pimterry @FullstackJack @AdrianInsua
What steps need to take place at this point in time in order to merge in this PR (other than the obvious merge conflict)?
I am seeing a much more severe StrictMode issue (in line with #624) on React version 17.0.1 with react-autosuggest 10.0.4

Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code.
Warning: Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning about componentWillReceiveProps in React's Strict Mode
5 participants