react-isomorphic-boilerplate
Advanced tools
Comparing version 0.5.0 to 0.5.1
{ | ||
"name": "react-isomorphic-boilerplate", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"main": "src/server/index.js", | ||
@@ -35,5 +35,6 @@ "license": "MIT", | ||
"eslint": "^4.9.0", | ||
"eslint-config-airbnb-base": "^12.1.0", | ||
"eslint-config-airbnb": "^16.1.0", | ||
"eslint-loader": "^1.9.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.3", | ||
"eslint-plugin-react": "^7.4.0", | ||
@@ -40,0 +41,0 @@ "extract-text-webpack-plugin": "^3.0.2", |
@@ -8,3 +8,4 @@ import React from 'react'; | ||
margin: '5rem 0', | ||
}}> | ||
}} | ||
> | ||
404 not found | ||
@@ -11,0 +12,0 @@ </div> |
@@ -1,2 +0,1 @@ | ||
/* eslint class-methods-use-this: 0 */ | ||
import React from 'react'; | ||
@@ -6,21 +5,17 @@ import { Link } from 'react-router-dom'; | ||
export default class AnotherEntry extends React.Component { | ||
static propTypes = {} | ||
const AnotherEntry = () => ( | ||
<div className="page--another-entry"> | ||
<h2> this is another entry</h2> | ||
<p> | ||
<Link to="/">use {'<Link />'}</Link> to home would not work | ||
</p> | ||
<div> | ||
<p> | ||
you have to use {'<a>'} tag <a href="/">like here</a> | ||
</p> | ||
<small>Remember: you would lose benefit of SPA if doing so</small> | ||
</div> | ||
</div> | ||
); | ||
render() { | ||
return ( | ||
<div className="page--another-entry"> | ||
<h2> this is another entry</h2> | ||
<p> | ||
<Link to="/">use {'<Link />'}</Link> to home would not work | ||
</p> | ||
<div> | ||
<p> | ||
you have to use {'<a>'} tag <a href="/">like here</a> | ||
</p> | ||
<small>Remember: you would lose benefit of SPA if doing so</small> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
export default AnotherEntry; |
@@ -1,2 +0,1 @@ | ||
/* eslint class-methods-use-this: 0 */ | ||
import React from 'react'; | ||
@@ -10,16 +9,14 @@ import stdout from '../../stdout'; | ||
export default class Demo extends React.Component { | ||
render() { | ||
return ( | ||
<div className="page--demo"> | ||
<h1 className="demo--font"> | ||
Title in Spectral SC | ||
A red flair silhouetted the jagged edge of a wing | ||
</h1> | ||
const Demo = () => ( | ||
<div className="page--demo"> | ||
<h1 className="demo--font"> | ||
Title in Spectral SC | ||
A red flair silhouetted the jagged edge of a wing | ||
</h1> | ||
<div className="demo--bg"></div> | ||
<img className="demo--img-src" src={logoImg} /> | ||
</div> | ||
); | ||
} | ||
} | ||
<div className="demo--bg" /> | ||
<img className="demo--img-src" alt="" src={logoImg} /> | ||
</div> | ||
); | ||
export default Demo; |
@@ -1,13 +0,10 @@ | ||
/* eslint class-methods-use-this: 0 */ | ||
import React from 'react'; | ||
import './style.scss'; | ||
export default class Footer extends React.Component { | ||
render() { | ||
return ( | ||
<div className="footer"> | ||
<a href="https://github.com/ddhp/react-isomorphic-boilerplate" target="_blank" rel="noopener noreferrer">react isomorphic boilerplate</a> by ddhp | ||
</div> | ||
); | ||
} | ||
} | ||
const Footer = () => ( | ||
<div className="footer"> | ||
<a href="https://github.com/ddhp/react-isomorphic-boilerplate" target="_blank" rel="noopener noreferrer">react isomorphic boilerplate</a> by ddhp | ||
</div> | ||
); | ||
export default Footer; |
@@ -12,6 +12,10 @@ import React from 'react'; | ||
static propTypes = { | ||
addPost: PropTypes.func, | ||
addPost: PropTypes.func.isRequired, | ||
name: PropTypes.string, | ||
} | ||
static defaultProps = { | ||
name: '', | ||
} | ||
static validateShowError = text => text.length < 256 | ||
@@ -18,0 +22,0 @@ |
@@ -16,6 +16,10 @@ import React from 'react'; | ||
static propTypes = { | ||
dummyAction: PropTypes.func, | ||
posts: PropTypes.array, | ||
dummyAction: PropTypes.func.isRequired, | ||
posts: PropTypes.arrayOf(PropTypes.number), | ||
} | ||
static defaultProps = { | ||
posts: [], | ||
} | ||
componentDidMount() { | ||
@@ -22,0 +26,0 @@ this.props.dummyAction(); |
@@ -8,8 +8,21 @@ import React from 'react'; | ||
const postItemShape = { | ||
arthur: PropTypes.string, | ||
createdAt: PropTypes.number, | ||
downvote: PropTypes.number, | ||
id: PropTypes.number, | ||
text: PropTypes.string, | ||
upvote: PropTypes.number, | ||
}; | ||
export class Postlist extends React.Component { | ||
static propTypes = { | ||
post: PropTypes.object, | ||
vote: PropTypes.func, | ||
post: PropTypes.objectOf(PropTypes.shape(postItemShape)), | ||
vote: PropTypes.func.isRequired, | ||
} | ||
static defaultProps = { | ||
post: {}, | ||
} | ||
constructor(props) { | ||
@@ -43,2 +56,3 @@ super(props); | ||
<div className="text"> | ||
{/* eslint-disable react/no-array-index-key */} | ||
{p.text.split('\n').map((paragraph, i) => <p key={i}>{paragraph}</p>)} | ||
@@ -45,0 +59,0 @@ </div> |
@@ -8,23 +8,23 @@ import React from 'react'; | ||
export class Nav extends React.Component { | ||
static propTypes = { | ||
name: PropTypes.string, | ||
} | ||
const Nav = ({ name }) => ( | ||
<nav> | ||
<Link to="/">Rib.</Link> | ||
<Link to="/about">About</Link> | ||
<Link to="/demo">Demo</Link> | ||
<a href="another-entry">Another</a> | ||
render() { | ||
return ( | ||
<nav> | ||
<Link to="/">Rib.</Link> | ||
<Link to="/about">About</Link> | ||
<Link to="/demo">Demo</Link> | ||
<a href="another-entry">Another</a> | ||
<div className="user-info"> | ||
your are {name} | ||
</div> | ||
</nav> | ||
); | ||
<div className="user-info"> | ||
your are {this.props.name} | ||
</div> | ||
</nav> | ||
); | ||
} | ||
} | ||
Nav.propTypes = { | ||
name: PropTypes.string, | ||
}; | ||
Nav.defaultProps = { | ||
name: '', | ||
}; | ||
function mapStateToProps(state) { | ||
@@ -31,0 +31,0 @@ const entities = _get(state, 'entities'); |
@@ -25,37 +25,40 @@ import React from 'react'; | ||
export class AnotherOneRoute extends React.Component { | ||
static propTypes = { | ||
location: PropTypes.object, | ||
export const AnotherOneRoute = ({ location }) => { | ||
const routesInfo = getRoutes(); | ||
const currentRoute = getMatchedRoute(location.pathname, routesInfo); | ||
let { redirect } = currentRoute; | ||
if (currentRoute.redirect && _isFunction(currentRoute.redirect)) { | ||
redirect = currentRoute.redirect(); | ||
} | ||
render() { | ||
const { location } = this.props; | ||
const routesInfo = getRoutes(); | ||
const currentRoute = getMatchedRoute(location.pathname, routesInfo); | ||
return ( | ||
<div> | ||
<Helmet titleTemplate="%s - by ddhp"> | ||
<title>Another One Route</title> | ||
<meta name="description" content="react isomorphic boilerplate by ddhp" /> | ||
<meta name="og:title" content="Another One Route" /> | ||
</Helmet> | ||
<h1 style={{ | ||
fontFamily: 'Spectral SC, serif', | ||
margin: '2rem', | ||
textAlign: 'center', | ||
}} | ||
><a href="/">Rib.</a> | ||
</h1> | ||
{renderRoutes(routesInfo.routes, redirect)} | ||
<Footer /> | ||
</div> | ||
); | ||
}; | ||
let { redirect } = currentRoute; | ||
AnotherOneRoute.propTypes = { | ||
location: PropTypes.objectOf(PropTypes.string), | ||
}; | ||
if (currentRoute.redirect && _isFunction(currentRoute.redirect)) { | ||
redirect = currentRoute.redirect(); | ||
} | ||
AnotherOneRoute.defaultProps = { | ||
location: {}, | ||
}; | ||
return ( | ||
<div> | ||
<Helmet titleTemplate="%s - by ddhp"> | ||
<title>Another One Route</title> | ||
<meta name="description" content="react isomorphic boilerplate by ddhp" /> | ||
<meta name="og:title" content="Another One Route" /> | ||
</Helmet> | ||
<h1 style={{ | ||
fontFamily: 'Spectral SC, serif', | ||
margin: '2rem', | ||
textAlign: 'center', | ||
}}><a href="/">Rib.</a></h1> | ||
{renderRoutes(routesInfo.routes, redirect)} | ||
<Footer /> | ||
</div> | ||
); | ||
} | ||
} | ||
export default withRouter(AnotherOneRoute); |
@@ -62,34 +62,34 @@ import React from 'react'; | ||
export class MainRoute extends React.Component { | ||
static propTypes = { | ||
me: PropTypes.object, | ||
location: PropTypes.object, | ||
export const MainRoute = ({ location }) => { | ||
const routesInfo = getRoutes(); | ||
const currentRoute = getMatchedRoute(location.pathname, routesInfo); | ||
let { redirect } = currentRoute; | ||
if (currentRoute.redirect && _isFunction(currentRoute.redirect)) { | ||
redirect = currentRoute.redirect(); | ||
} | ||
render() { | ||
const { location/* , me */ } = this.props; | ||
const routesInfo = getRoutes(); | ||
const currentRoute = getMatchedRoute(location.pathname, routesInfo); | ||
return ( | ||
<div> | ||
<Helmet titleTemplate="%s - by ddhp"> | ||
<title>title set in entry-main</title> | ||
<meta name="description" content="react isomorphic boilerplate by ddhp" /> | ||
<meta name="og:title" content="title set in entry-main" /> | ||
</Helmet> | ||
<NavComponent /> | ||
{renderRoutes(routesInfo.routes, redirect)} | ||
<FooterComponent /> | ||
</div> | ||
); | ||
}; | ||
let { redirect } = currentRoute; | ||
MainRoute.propTypes = { | ||
location: PropTypes.objectOf(PropTypes.string), | ||
}; | ||
if (currentRoute.redirect && _isFunction(currentRoute.redirect)) { | ||
redirect = currentRoute.redirect(); | ||
} | ||
MainRoute.defaultProps = { | ||
location: {}, | ||
}; | ||
return ( | ||
<div> | ||
<Helmet titleTemplate="%s - by ddhp"> | ||
<title>title set in entry-main</title> | ||
<meta name="description" content="react isomorphic boilerplate by ddhp" /> | ||
<meta name="og:title" content="title set in entry-main" /> | ||
</Helmet> | ||
<NavComponent /> | ||
{renderRoutes(routesInfo.routes, redirect)} | ||
<FooterComponent /> | ||
</div> | ||
); | ||
} | ||
} | ||
function mapStateToProps(state) { | ||
@@ -96,0 +96,0 @@ return { |
@@ -44,7 +44,11 @@ import React from 'react'; | ||
return ( | ||
<Route key={key} {...rest} render={props => ( | ||
<div> | ||
<Component {...props} /> | ||
</div> | ||
)} /> | ||
<Route | ||
key={key} | ||
{...rest} | ||
render={props => ( | ||
<div> | ||
<Component {...props} /> | ||
</div> | ||
)} | ||
/> | ||
); | ||
@@ -51,0 +55,0 @@ })} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
488160
1830
43