-
-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Basic Generator & Linters (#624)
* Update basic generator so that the basic example is simpler * All files registered for react on rails go in the registration.js file.
- Loading branch information
Showing
29 changed files
with
145 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<h1>Hello World</h1> | ||
<%%= react_component("HelloWorldApp", props: @hello_world_props, prerender: false) %> | ||
<%%= react_component("<%= config[:component_name] %>", props: @hello_world_props, prerender: false) %> | ||
|
45 changes: 45 additions & 0 deletions
45
...eact_on_rails/templates/base/base/client/app/bundles/HelloWorld/components/HelloWorld.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { PropTypes } from 'react'; | ||
|
||
export default class HelloWorld extends React.Component { | ||
static propTypes = { | ||
name: PropTypes.string.isRequired, // this is passed from the Rails view | ||
}; | ||
|
||
/** | ||
* @param props - Comes from your rails view. | ||
* @param _railsContext - Comes from React on Rails | ||
*/ | ||
constructor(props, _railsContext) { | ||
super(props); | ||
|
||
// How to set initial state in ES6 class syntax | ||
// https://facebook.github.io/react/docs/reusable-components.html#es6-classes | ||
this.state = { name: this.props.name }; | ||
} | ||
|
||
updateName = (name) => { | ||
this.setState({ name }); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<h3> | ||
Hello, {this.state.name}! | ||
</h3> | ||
<hr /> | ||
<form > | ||
<label htmlFor="name"> | ||
Say hello to: | ||
</label> | ||
<input | ||
id="name" | ||
type="text" | ||
value={this.state.name} | ||
onChange={(e) => this.updateName(e.target.value)} | ||
/> | ||
</form> | ||
</div> | ||
); | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
...t_on_rails/templates/base/base/client/app/bundles/HelloWorld/components/HelloWorld.jsx.tt
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
...ct_on_rails/templates/base/base/client/app/bundles/HelloWorld/startup/registration.jsx.tt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import ReactOnRails from 'react-on-rails'; | ||
|
||
import <%= config[:component_name] %> from '<%= config[:app_relative_path] %>'; | ||
|
||
// This is how react_on_rails can see the HelloWorld in the browser. | ||
ReactOnRails.register({ | ||
<%= config[:component_name] %>, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
.../templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
..._rails/templates/no_redux/base/client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx.tt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.