-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
[createReactClass] remove createReactClass from RNTester/js/ImageExample.js #21602
[createReactClass] remove createReactClass from RNTester/js/ImageExample.js #21602
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good, but I think we should make a few changes. 🧐
I think there's a lot of cases where we're using the source
prop type. It's copy-pasted 4 times. It'd probably be better if we pull it out into its own type and re-use it. Something like:
type ImageSource = $ReadOnly<|uri: string|>;
Since we're forwarding the source to the Image
component anyway, we could (or maybe we should) just also do:
type ImageProps = React.ElementProps<typeof Image>;
type ImageSource = $ElementType<ImageProps, 'source'>
RNTester/js/ImageExample.js
Outdated
}; | ||
|
||
type NetworkImageCallbackExampleState = { | ||
events: string[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: For consistency, we should use: Array<string>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
RNTester/js/ImageExample.js
Outdated
}, | ||
prefetchedSource: { | ||
uri: string, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flow's $ReadOnly
(like Object.freeze
) only goes 1 layer deep. We should probably change this to:
type NetworkImageCallbackExampleProps = $ReadOnly<{|
source: $ReadOnly<{|
uri: string,
|}>,
prefetchedSource: $ReadOnly<{|
uri: string,
|}>,
|}>;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!!
I didn't understand Flow's $ReadOnly (like Object.freeze) only goes 1 layer deep
RNTester/js/ImageExample.js
Outdated
NetworkImageCallbackExampleProps, | ||
NetworkImageCallbackExampleState, | ||
> { | ||
static displayName: ?string = 'NetworkImageCallbackExample'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, no need for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
RNTester/js/ImageExample.js
Outdated
}; | ||
|
||
type ImageSizeExampleProps = $ReadOnly<{| | ||
source: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type ImageSizeExampleProps = $ReadOnly<{|
source: $ReadOnly<{|
uri: string,
|}>
|}>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
RNTester/js/ImageExample.js
Outdated
}; | ||
|
||
class MultipleSourcesExample extends React.Component< | ||
{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can we move this out to MultipleSourcesExampleProps
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 👍🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RSNara has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@nd-02110114 merged commit 897f721 into |
Summary: Related to #21581 . Removed createReactClass from the RNTester/js/ImageExample.js The diff of this PR is a little big. If there are any problems, please teach me � - [x] npm run prettier - [x] npm run flow-check-ios - [x] npm run flow-check-android [GENERAL] [ENHANCEMENT] [RNTester/js/ImageExample.js] - remove createReactClass dependency Pull Request resolved: facebook/react-native#21602 Reviewed By: TheSavior Differential Revision: D10304857 Pulled By: RSNara fbshipit-source-id: 339b1220828c6218cad0d09c7a5034a61e623bc6
) Summary: Related to facebook#21581 . Removed createReactClass from the RNTester/js/ImageExample.js The diff of this PR is a little big. If there are any problems, please teach me � - [x] npm run prettier - [x] npm run flow-check-ios - [x] npm run flow-check-android [GENERAL] [ENHANCEMENT] [RNTester/js/ImageExample.js] - remove createReactClass dependency Pull Request resolved: facebook#21602 Reviewed By: TheSavior Differential Revision: D10304857 Pulled By: RSNara fbshipit-source-id: 339b1220828c6218cad0d09c7a5034a61e623bc6
Related to #21581 .
Removed createReactClass from the RNTester/js/ImageExample.js
The diff of this PR is a little big. If there are any problems, please teach me 🙇
Test Plan
Release Notes
[GENERAL] [ENHANCEMENT] [RNTester/js/ImageExample.js] - remove createReactClass dependency