GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Verify that the component passed to createAnimatedComponent is not functional by janicduplessis · Pull Request #15019 · react/react-native Conversation
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to check this? It does work but meh...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
5f55c4a to
704fbd5
Compare
|
@sahrens Could you have a look at this? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
@facebook-github-bot label Needs more information @facebook-github-bot label Core Team Generated by 🚫 dangerJS |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Hmm, is this the best way to check? I thought React had some helper functions that would be more robust.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| const invariant = require('fbjs/lib/invariant'); | ||
|
|
||
| function createAnimatedComponent(Component: any): any { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For Flow checking within the RN codebase, you could add something like this:
createAnimatedComponent<P>( Component: Class<React.Component<P>> ): Class<React.Component<*>> { ... }
I believe this will filter out functions too.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I remember trying to type this properly but I hit some issue. React components typing changed in flow 0.53 I can try again to see if I can figure out something that works.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@sahrens Yea I’m not sure if there is a better way, I commented on the diff to ask that but it doesn’t show up since I rebased. Maybe ask someone from the react team. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@bvaughn Is there a public API to check if a component is functional? (needed to know if refs are available). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
FWIW we use this type of duck typing in React too (eg
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@janicduplessis I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
704fbd5 to
affbd87
Compare
|
Thanks @bvaughn ! Update to use @ide I played with trying to flow type it properly again but there was an issue with default props, it didn't seem to pick it up properly anymore so it caused a bunch of errors where some props that should not be required were. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Whoops, sorry for not seeing your earlier update. This looks good to me.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| function createAnimatedComponent(Component: any): any { | ||
| invariant( | ||
| Component.prototype && Component.prototype.isReactComponent, | ||
| '`createAnimatedComponent` does not support stateless functional components, ' + |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
tiny nit: "," should be a ";" I think
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'll trust you on that one. I never know when ; should be used, I guess I wasn't listening at school that day :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@janicduplessis would you want to rebase this? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@ide Looks like tests need to be updated to pass this new check, will try to find some time to update this soon. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Updated and re-tested, we actually need to allow string components too since in prod views are just RCTView strings. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@sahrens is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.