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
Prevent the context from changing which forces unnecessary rerenders #2373
Conversation
One note is I'm not entirely sure what other bugs this may bring out that were being hidden by the constant re-renders |
@Johan-dutoit looks good to me. This seems to fix some lag! |
Looks good to me! |
@Johan-dutoit would you mind taking a look at this? |
Defo want to merge this in. Please resolve conflicts 🙏 |
@mdkwock please resolve conflicts if you can. If not, I can try soon! @Johan-dutoit this is a much needed change since this makes everything work a lot faster! 🐎 Kudos to @mdkwock for tackling this. |
@mdkwock @Johan-dutoit |
@amerikan i would probably rewrite what i wrote to not use state, and instead use |
@mdkwock thanks for the feedback! The other PR is one of my many planned iterations to modernize the main component now that's using functional components with hooks. I just threw in your modifications as a separate commit so that the library is useable as soon as possible. |
@amerikan @Johan-dutoit okay resolved conflicts and updated to use useMemo as my comment stated, i think it's cleaner looking than using state. |
@mdkwock nice! I just removed the commit from my PR since you're addressing it here. @Johan-dutoit when you merge this, it'll be good to bump version on npm 🙏🏼 |
@amerikan FYI bumping npm is unavailable until the typescript/eslint errors are resolved. |
Fixes #2370 by saving the context as a state object so the object doesn't change. Currently whenever the GiftedChat component re-renders it causes the context to change as the context is given a new value. this causes all the components that rely on the context to update, which is a lot of them.