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

[Navigator] Support the ref prop on scene roots #1361

Closed
wants to merge 1 commit into from

Conversation

ide
Copy link
Contributor

@ide ide commented May 21, 2015

Navigator overrides the ref prop of scene components so that it can call onItemRef and do internal bookkeeping. With callback refs, we can additionally call the original value of the ref prop as long as it's a function (that is, string refs are not supported). Note that the ref prop is moved to reactElement.ref out of reactElement.props.ref, which is why this diff accesses child.ref.

This diff adds support for callback refs and warns helpfully if a string ref was provided. It should be completely backwards compatible since scenes couldn't have been relying on the ref prop before.

cc @ericvicenti

Test Plan: Write a renderScene implementation that puts a callback ref on the root component:

renderScene() {
  return <View ref={component => console.log('yes! this is called')} />;
}

Navigator overrides the `ref` prop of scene components so that it can call `onItemRef` and do internal bookkeeping. With callback refs, we can additionally call the original value of the `ref` prop as long as it's a function (that is, string refs are not supported). Note that the `ref` prop is moved to `reactElement.ref` out of `reactElement.props.ref`, which is why this diff accesses `child.ref`.

This diff adds support for callback refs and warns helpfully if a string ref was provided. It should be completely backwards compatible since scenes couldn't have been relying on the `ref` prop before.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 21, 2015
@ericvicenti
Copy link
Contributor

Brilliant! This is why function refs are so much better. Thanks for fixing this, @ide

@facebook-github-bot import

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1663226797244458/int_phab to review.

@sophiebits
Copy link
Contributor

Nice.

@ide ide closed this in 7f51f9c May 22, 2015
@ide ide deleted the scene-refs branch June 10, 2015 02:43
ayushjainrksh pushed a commit to MLH-Fellowship/react-native that referenced this pull request Jul 2, 2020
facebook#1361)

* Replace current 14 'showcase' brands to scaled images (68x68)

* Resize the 14 images to be '100x100' instead of '68x68'

* perf: Optimize 14 showcase images (200x200)

* file: Add 200x200 'artsy' optimized logo
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants