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

[CLI] Validation check for "React" package name #1384

Merged
merged 2 commits into from
May 25, 2015

Conversation

dsibiski
Copy link
Contributor

React (with a capital) should be a reserve word and should not be used as a project name since it will break the Sample app when generated.

Previously, the CLI replaced all occurrences of SampleApp with whatever the user specified. If they happen to input 'React', it would generate this:

var React = React.createClass({ ...

...

AppRegistry.registerComponent('React', () => React);

...which is a redefinition of React, causing createClass to not be defined, in turn causing the app to crash on the very first run after init, without the user modifying anything.

This commit adds a validation check prompting the user that React is not a valid project name.

Discussion here: http://stackoverflow.com/a/30416864/4932710

- "React" is a reserve word and cannot be used as a project name since it will break the Sample app when generated
@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels May 23, 2015
@ide
Copy link
Contributor

ide commented May 23, 2015

Nice catch. With babel we may also want to use const with all requires so the transformer catches this.

@a2 a2 assigned vjeux May 24, 2015
vjeux added a commit that referenced this pull request May 25, 2015
[CLI] Validation check for "React" package name
@vjeux vjeux merged commit 68718fd into facebook:master May 25, 2015
@vjeux
Copy link
Contributor

vjeux commented May 25, 2015

Nice, more warnings to prevent mistakes :)

@ide: what would fix that is for the packager to yell at you if you have two modules with the same name. Right now, it just picks a random one. Internally we've got a lot of duplicates but hopefully we'll be able to remove them and start warning instead of this very bad behavior.

@ide
Copy link
Contributor

ide commented May 25, 2015

The packager already breaks if there are two @providesModules with the name name (or it used to a couple weeks ago). In this case the index.ios.js file doesn't have a haste header, it's just that there are two variables with the same name.

ayushjainrksh pushed a commit to MLH-Fellowship/react-native that referenced this pull request Jul 2, 2020
* Fix lint rules in v0.44

* Fix up .alexignore
mganandraj pushed a commit to mganandraj/react-native that referenced this pull request Aug 28, 2022
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.

4 participants