forked from facebook/create-react-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for adding react-router and examples
- Loading branch information
Showing
3 changed files
with
73 additions
and
23 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { Component } from 'react'; | ||
{% if router -%} | ||
import { HashRouter as Router, Link, Route } from 'react-router-dom'; | ||
{%- endif %} | ||
|
||
import logo from './logo.svg'; | ||
import './App.css'; | ||
{% if redux -%} | ||
import IncrementButton from './containers/IncrementButton'; | ||
{%- endif %} | ||
|
||
{% if router -%} | ||
const Home = () => ( | ||
<div> | ||
<h3>Home</h3> | ||
{% if redux -%} | ||
<IncrementButton /> | ||
{%- endif %} | ||
</div> | ||
); | ||
const Foo = () => ( | ||
<h3>Foo</h3> | ||
); | ||
const Bar = () => ( | ||
<h3>Bar</h3> | ||
); | ||
const Baz = () => ( | ||
<h3>Baz</h3> | ||
); | ||
{%- endif %} | ||
|
||
class App extends Component { | ||
render() { | ||
return ( | ||
{% if router -%} | ||
<Router> | ||
{%- endif %} | ||
<div className="App"> | ||
<div className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<h2>Welcome to React</h2> | ||
</div> | ||
<p className="App-intro"> | ||
To get started, edit <code>src/App.js</code> and save to reload. | ||
</p> | ||
{% if router -%} | ||
<Link to="/" replace>Home</Link> | <Link to="/foo" replace>Foo</Link> | <Link to="/bar" replace>Bar</Link> | <Link to="/baz" replace>Baz</Link> | ||
<Route exact path="/" component={Home} /> | ||
<Route path="/foo" component={Foo} /> | ||
<Route path="/bar" component={Bar} /> | ||
<Route path="/baz" component={Baz} /> | ||
{%- elif redux -%} | ||
<IncrementButton /> | ||
{%- endif %} | ||
</div> | ||
{% if router -%} | ||
</Router> | ||
{%- endif %} | ||
); | ||
} | ||
} | ||
|
||
export default App; |
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,8 +1,16 @@ | ||
'use strict'; | ||
|
||
module.exports = (currentDependencies, { bootstrap, fontawesome, redux }) => { | ||
module.exports = (currentDependencies, { bootstrap, fontawesome, redux, router }) => { | ||
const boostrapDependencies = bootstrap ? { "bootstrap": "3.3.7", "react-bootstrap": "0.31.0" } : {}; | ||
const fontawesomeDependencies = fontawesome ? { "font-awesome": "4.7.0", "react-fontawesome": "1.6.1" } : {}; | ||
const reduxDependencies = redux ? { "redux": "3.6.0", "redux-thunk": "2.2.0", "redux-promise": "0.5.3", "redux-logger": "3.0.1", "redux-actions": "2.0.2", "react-redux": "5.0.4" } : {}; | ||
return Object.assign({}, currentDependencies, boostrapDependencies, fontawesomeDependencies, reduxDependencies); | ||
const routerDependencies = router ? { "react-router-dom": "4.1.1" } : {}; | ||
return Object.assign( | ||
{}, | ||
currentDependencies, | ||
boostrapDependencies, | ||
fontawesomeDependencies, | ||
reduxDependencies, | ||
routerDependencies | ||
); | ||
} |