Skip to content

Guard against unmounted components when accessing public instances on Fabric (#27687)#41452

Closed
rubennorte wants to merge 1 commit into
facebook:mainfrom
rubennorte:export-D51203276
Closed

Guard against unmounted components when accessing public instances on Fabric (#27687)#41452
rubennorte wants to merge 1 commit into
facebook:mainfrom
rubennorte:export-D51203276

Conversation

@rubennorte
Copy link
Copy Markdown
Contributor

Summary:

Summary

This fixes an error in getPublicInstanceFromInstanceHandle where we
throw an error when trying to access the public instance from the fiber
of an unmounted component. This shouldn't throw but return null
instead.

How did you test this change?

Updated unit tests.
Before:
Screenshot 2023-11-10 at 15 26 14

After:
Screenshot 2023-11-10 at 15 28 37

DiffTrain build for commit facebook/react@6b3834a.

Reviewed By: tyao1

Differential Revision: D51203276

Pulled By: tyao1

… Fabric (facebook#27687)

Summary:
## Summary

This fixes an error in `getPublicInstanceFromInstanceHandle` where we
throw an error when trying to access the public instance from the fiber
of an unmounted component. This shouldn't throw but return `null`
instead.

## How did you test this change?

Updated unit tests.
Before:
<img width="969" alt="Screenshot 2023-11-10 at 15 26 14"
src="https://github.com/facebook/react/assets/117921/ea161616-2775-4fab-8d74-da4bef48d09a">

After:
<img width="1148" alt="Screenshot 2023-11-10 at 15 28 37"
src="https://github.com/facebook/react/assets/117921/db18b918-b6b6-4925-9cfc-3b4b2f3ab92d">

DiffTrain build for commit facebook/react@6b3834a.

Reviewed By: tyao1

Differential Revision: D51203276

Pulled By: tyao1
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Nov 13, 2023
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D51203276

rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
… Fabric (facebook#27687) (facebook#41452)

Summary:

## Summary

This fixes an error in `getPublicInstanceFromInstanceHandle` where we
throw an error when trying to access the public instance from the fiber
of an unmounted component. This shouldn't throw but return `null`
instead.

## How did you test this change?

Updated unit tests.
Before:
<img width="969" alt="Screenshot 2023-11-10 at 15 26 14"
src="https://github.com/facebook/react/assets/117921/ea161616-2775-4fab-8d74-da4bef48d09a">

After:
<img width="1148" alt="Screenshot 2023-11-10 at 15 28 37"
src="https://github.com/facebook/react/assets/117921/db18b918-b6b6-4925-9cfc-3b4b2f3ab92d">

DiffTrain build for commit facebook/react@6b3834a.

Test Plan: Sandcastle tests

Reviewed By: tyao1

Differential Revision: D51203276

Pulled By: tyao1
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 14, 2023
… Fabric (facebook#27687) (facebook#41452)

Summary:

## Summary

This fixes an error in `getPublicInstanceFromInstanceHandle` where we
throw an error when trying to access the public instance from the fiber
of an unmounted component. This shouldn't throw but return `null`
instead.

## How did you test this change?

Updated unit tests.
Before:
<img width="969" alt="Screenshot 2023-11-10 at 15 26 14"
src="https://github.com/facebook/react/assets/117921/ea161616-2775-4fab-8d74-da4bef48d09a">

After:
<img width="1148" alt="Screenshot 2023-11-10 at 15 28 37"
src="https://github.com/facebook/react/assets/117921/db18b918-b6b6-4925-9cfc-3b4b2f3ab92d">

DiffTrain build for commit facebook/react@6b3834a.

Test Plan: Sandcastle tests

Reviewed By: tyao1

Differential Revision: D51203276

Pulled By: tyao1
@github-actions
Copy link
Copy Markdown

This pull request was successfully merged by @rubennorte in e0aa9ab.

When will my fix make it into a release? | Upcoming Releases

@github-actions github-actions Bot added the Merged This PR has been merged. label Nov 14, 2023
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@rubennorte merged this pull request in e0aa9ab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants