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

[core] fix(PanelStack2): more stable controlled mode #4808

Merged
merged 2 commits into from
Jul 15, 2021

Conversation

adidahiya
Copy link
Contributor

Fixes #4807

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

  • Avoid React "inconsistent number of hook called" errors with two changes to the PanelStack2 implementation:
    • Move PanelStack2's early return in its render path to after all hooks are called
    • Wrap each renderPanel() call in a simple functional component wrapper to encapsulate the lifecycle of any hooks potentially called inside those functions
  • Fix the PanelStack2 docs example state management to append and remove panels from the end of the stack array, rather than the beginning
    • The test suite and docs example were inconsistent about this. I believe the test suite had the correct behavior, and I've updated the docs to point this out for controlled mode users.

Reviewers should focus on:

  • Any performance implications of the new <PanelWrapper />

Screenshot

2021-07-14 22 46 43

@adidahiya adidahiya requested a review from invliD July 15, 2021 02:51
@blueprint-bot
Copy link

address sebastian's PR comments

Previews: documentation | landing | table

@adidahiya adidahiya merged commit 03c6cae into develop Jul 15, 2021
@adidahiya adidahiya deleted the ad/fix-panelstack-crash branch July 15, 2021 16:14
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.

PanelStack2 crashes due to inconsistent number of hooks called
3 participants