Skip to content

fix(ios): initialContext not always set before name #17

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

Merged
merged 2 commits into from
Jul 1, 2022

Conversation

Steven0351
Copy link
Contributor

fix(ios): Application of props is not guaranteed to be in any specific order. Setting initialContext may occur before the name prop is set and therefore will be unable to set any initialContext. To address this, we now store the initialContext on the view itself and then apply it to the portal just before rendering.

order. Setting initialContext may occur before the name prop is set and
therefore will be unable to set any initialContext. To address this, we now store
the initialContext on the view itself and then apply it to the portal
just before rendering.
@Steven0351 Steven0351 marked this pull request as draft July 1, 2022 03:51
@Steven0351 Steven0351 marked this pull request as ready for review July 1, 2022 04:21
@Steven0351
Copy link
Contributor Author

This is a bit of an issue for both iOS and Android, where we need to do manual housekeeping to make sure we can render with any potential overridden initialContext. I think in a future release it would make sense to make these into one prop instead of two separate values. This would make the callsite look like this:

<PortalView 
  portal={{ name: 'help', initialContext: { startingRoute: '/help' } }}
  style={{ flex: 1 }}
/>

instead of this:

<PortalView
  name='help'
  initialContext={{ startingRoute: '/help' }}
  style={{ flex: 1 }}
/>

This is more of an issue right now on iOS because setting initialContext is triggering the didSet method of the _portal variable at least twice in some cases, which adds and removes the PortalUIView each time. If (or when) Android has a View based PortalView, the same issue would likely arise there as well.

@Steven0351 Steven0351 merged commit 5ebef45 into main Jul 1, 2022
@Steven0351 Steven0351 deleted the fix-ios-initial-context branch July 1, 2022 15:20
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.

3 participants