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

[createReactClass] remove createReactClass from RNTester/js/ImageExample.js #21602

Conversation

nissy-dev
Copy link
Contributor

@nissy-dev nissy-dev commented Oct 9, 2018

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

  • npm run prettier
  • npm run flow-check-ios
  • npm run flow-check-android

Release Notes

[GENERAL] [ENHANCEMENT] [RNTester/js/ImageExample.js] - remove createReactClass dependency

@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 Oct 9, 2018
@RSNara RSNara changed the title remove createReactClass from RNTester/js/ImageExample.js [createReactClass] remove createReactClass from RNTester/js/ImageExample.js Oct 9, 2018
Copy link
Contributor

@RSNara RSNara left a 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'>

};

type NetworkImageCallbackExampleState = {
events: string[],
Copy link
Contributor

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>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

RNTester/js/ImageExample.js Show resolved Hide resolved
},
prefetchedSource: {
uri: string,
},
Copy link
Contributor

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,
  |}>,
|}>;

Copy link
Contributor Author

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

NetworkImageCallbackExampleProps,
NetworkImageCallbackExampleState,
> {
static displayName: ?string = 'NetworkImageCallbackExample';
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

};

type ImageSizeExampleProps = $ReadOnly<{|
source: {
Copy link
Contributor

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,
  |}>
|}>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

};

class MultipleSourcesExample extends React.Component<
{},
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@RSNara RSNara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍🏼

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@react-native-bot
Copy link
Collaborator

@nd-02110114 merged commit 897f721 into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Oct 10, 2018
@react-native-bot react-native-bot added the Merged This PR has been merged. label Oct 10, 2018
rozele pushed a commit to microsoft/react-native-windows that referenced this pull request Apr 14, 2019
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
t-nanava pushed a commit to microsoft/react-native-macos that referenced this pull request Jun 17, 2019
)

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants