Skip to content

Conversation

ide
Copy link
Contributor

@ide ide commented Mar 14, 2016

Fixes an issue where if you implement renderScrollComponent and have a ref callback on the returned element, the ref used to be clobbered by the ref that ListView adds to the element.

This is accomplished by converting the ref from a legacy string-based ref to a callback-based ref, and then using cloneReferencedElement, which is a simple utility to compose callback refs.

Test Plan: Open the ListView examples in UIExplorer (iOS)

Fixes an issue where if you implement `renderScrollComponent` and have a `ref` callback on the returned element, the ref is not clobbered by the ref that ListView adds to the the element.

This is accomplished by converting the ref from a legacy string-based ref to a callback-based ref, and then using `cloneReferencedElement`, which is a simple utility to compose callback refs.

Test Plan: Open the ListView examples in UIExplorer
@ide
Copy link
Contributor Author

ide commented Mar 14, 2016

Note that this adds a small dep to package.json, so it'll be necessary to rebuild npm-shrinkwrap.json.

@facebook-github-bot
Copy link
Contributor

@ide updated the pull request.

@facebook-github-bot
Copy link
Contributor

@ide updated the pull request.

@skevy
Copy link
Contributor

skevy commented Mar 17, 2016

FYI @ide we removed shrinkwrap from master (but are still shipping it to NPM), so no need to worry about dep updates and updating shrinkwrap for PRs anymore.

@skevy
Copy link
Contributor

skevy commented Mar 17, 2016

Looks good to me.

@skevy
Copy link
Contributor

skevy commented Mar 17, 2016

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to Phabricator to review.

@skevy
Copy link
Contributor

skevy commented Mar 18, 2016

@mkonicek this failed for some reason...not sure why

@mkonicek
Copy link
Contributor

The error is:

Unable to resolve module react-clone-referenced-element

It's likely because this PR changes package.json and need to import it manually into the fb npm cache.

Any PRs that touch package.json need manual import. Can you do this without adding a dependency? Just an idea.

@skevy
Copy link
Contributor

skevy commented Mar 18, 2016

I'll let @ide speak to that. It's a small dep...just a function...it could possibly live within RN...but shouldn't be a big deal to add as a dependency.

@ide
Copy link
Contributor Author

ide commented Mar 18, 2016

It's a small dep and pretty stable unless React's ref API changes. There is at least one other place in the codebase (Navigator) that needs this behavior too, though, so having it be a shared helper function makes the most sense to me. And most React libs that clone elements and set refs should be using this, so that's why the helper is published to npm.

@mkonicek
Copy link
Contributor

OK that makes sense, need to find some time to import react-clone-referenced-element into our internal "npm cache" so that this will work internally :)

@ide
Copy link
Contributor Author

ide commented Mar 31, 2016

catping =)

4iazyrhy9rkis

@mkonicek
Copy link
Contributor

Haha nice macro! :) Sorry for the delay, I'll try to merge this tomorrow.

@mkonicek
Copy link
Contributor

mkonicek commented Apr 1, 2016

Removing the 'Import failed' label on this one. Using the 'Import failed' to track random failures we can fix. Automatically merging PRs that change package.json is unsupported and likely won't be for quite a long time (although it should be possible to implement).

@mkonicek
Copy link
Contributor

Trying to merge it internally now, sorry for the (long) delay!

@mkonicek
Copy link
Contributor

It's failing with an error installing node_modules from the internal cache in our CI. Looking into it, might have to wait for people in California. Merging PRs that change package.json is hard unfortunately.

@ghost ghost closed this in eaba2ab Apr 14, 2016
@ide ide deleted the listview-preserve-refs branch April 14, 2016 21:21
@mkonicek
Copy link
Contributor

It worked! 🎉 Sorry I forgot about it for 13 days :( Feel free to ping me on messenger next time.

@ide
Copy link
Contributor Author

ide commented Apr 14, 2016

@mkonicek thanks for pushing it though - appreciate it =)

@sebmarkbage
Copy link
Contributor

I'd recommend wrapping instead. Makes it a bit more seamless, doesn't take on another dependency, and is backwards compatible with old-style refs.

zebulgar pushed a commit to nightingale/react-native that referenced this pull request Jun 18, 2016
Summary:Fixes an issue where if you implement `renderScrollComponent` and have a `ref` callback on the returned element, the ref used to be clobbered by the ref that ListView adds to the element.

This is accomplished by converting the ref from a legacy string-based ref to a callback-based ref, and then using `cloneReferencedElement`, which is a simple utility to compose callback refs.
Closes facebook#6441

Differential Revision: D3064250

Pulled By: mkonicek

fb-gh-sync-id: 2d55d04e2144a1cc08900a57a1fc0dab07c87eea
fbshipit-source-id: 2d55d04e2144a1cc08900a57a1fc0dab07c87eea
This pull request was closed.
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.

5 participants