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

feature: Reactive modals #183

Merged
merged 1 commit into from
Jul 1, 2021

Conversation

Chef-Cheems
Copy link
Contributor

Backstory:
Currently components that are passed to the useModal() hook are rendered once and never update unless you close the modal and reopen it again. This causes a wide range of troubles since all modals are basically isolated from the rest of the app due to inability to update via prop changes.

This PR provides backwards-compatible way to make components passed to useModal() hook react to changes. By default all useModal() hooks behave as they always were, now you can pass 3d argument updateOnPropsChange if you want modal component to be reactive to prop changes. Also 4th argument modalId(just string id) is required if you have multiple useModal() hook on the page to prevent one modal updating instead of the other.

As noted in code comments - this solution feels a bit clunky and it would be better to rethink how we work with modals, its been creating quite a lot of issues lately. For now this is just quick backwards-compatible solution so we can move on with our plans.

@Chef-Cheems Chef-Cheems force-pushed the fix/reactive-use-modal branch from 7889244 to 0d9d140 Compare July 1, 2021 05:25
@RabbitDoge RabbitDoge merged commit 7644124 into pancakeswap:master Jul 1, 2021
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.

2 participants