mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Fix linting errors (#1235)
This commit is contained in:
parent
7d4d709587
commit
9ba7a10f85
|
@ -4,7 +4,7 @@ let storeMemoized = null
|
|||
|
||||
const getStore = (initialState) => {
|
||||
let store = null
|
||||
if (typeof window == 'undefined') {
|
||||
if (typeof window === 'undefined') {
|
||||
store = createStore(initialState)
|
||||
} else {
|
||||
if (!storeMemoized) {
|
||||
|
@ -15,4 +15,4 @@ const getStore = (initialState) => {
|
|||
return store
|
||||
}
|
||||
|
||||
export default getStore
|
||||
export default getStore
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { Provider} from 'refnux'
|
||||
|
||||
import {Provider} from 'refnux'
|
||||
import getStore from './getStore'
|
||||
|
||||
// The `withRefnux` "decorator"
|
||||
|
@ -9,12 +8,11 @@ import getStore from './getStore'
|
|||
// - passes `store` to Component's `getInitialProps` so that it can dispatch actions
|
||||
|
||||
const withRefnux = (getInitialState, Component) => {
|
||||
|
||||
const Wrapper = (props) => {
|
||||
var store = props.store
|
||||
// if getInitialProps was executed on the server we get a store
|
||||
// that's missing non-serializable functions.
|
||||
// Because of this we need to recreate the store based on the
|
||||
// Because of this we need to recreate the store based on the
|
||||
// state coming from the server.
|
||||
if (!store.dispatch) {
|
||||
store = getStore(props.store.state)
|
||||
|
@ -38,5 +36,4 @@ const withRefnux = (getInitialState, Component) => {
|
|||
return Wrapper
|
||||
}
|
||||
|
||||
|
||||
export default withRefnux
|
||||
export default withRefnux
|
||||
|
|
|
@ -14,7 +14,7 @@ const Page1 = connect(
|
|||
<h3>{state.title}</h3>
|
||||
<p>Current state: {JSON.stringify(state, null, 2)}</p>
|
||||
<button onClick={() => dispatch(counterIncrement)} >Increment</button>
|
||||
<Link href="/page2"><button>go to page 2</button></Link>
|
||||
<Link href='/page2'><button>go to page 2</button></Link>
|
||||
</div>
|
||||
)
|
||||
|
||||
|
@ -25,4 +25,4 @@ Page1.getInitialProps = async function (context) {
|
|||
return {} // we have a store, we don't need props!
|
||||
}
|
||||
|
||||
export default withRefnux(getInitialState, Page1)
|
||||
export default withRefnux(getInitialState, Page1)
|
||||
|
|
|
@ -14,7 +14,7 @@ const Page2 = connect(
|
|||
<h3>{state.title}</h3>
|
||||
<p>Current state: {JSON.stringify(state, null, 2)}</p>
|
||||
<button onClick={() => dispatch(counterIncrement)} >Increment</button>
|
||||
<Link href="/page1"><button>go to page 2</button></Link>
|
||||
<Link href='/page1'><button>go to page 2</button></Link>
|
||||
</div>
|
||||
)
|
||||
|
||||
|
@ -24,5 +24,4 @@ Page2.getInitialProps = async function (context) {
|
|||
return {}
|
||||
}
|
||||
|
||||
|
||||
export default withRefnux(getInitialState, Page2)
|
||||
export default withRefnux(getInitialState, Page2)
|
||||
|
|
|
@ -3,4 +3,4 @@ const counterIncrement = ({counter}, dispatch) => {
|
|||
return { counter: counter + 1 }
|
||||
}
|
||||
|
||||
export default counterIncrement
|
||||
export default counterIncrement
|
||||
|
|
|
@ -3,6 +3,6 @@ const getInitialState = () => {
|
|||
title: '',
|
||||
counter: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default getInitialState
|
||||
export default getInitialState
|
||||
|
|
|
@ -4,7 +4,7 @@ const storeInitialState = { counter: 0, key: 'value' }
|
|||
|
||||
const getStore = () => {
|
||||
let store = null
|
||||
if (typeof window == 'undefined') {
|
||||
if (typeof window === 'undefined') {
|
||||
store = createStore(storeInitialState)
|
||||
} else {
|
||||
store = window.store || createStore(storeInitialState)
|
||||
|
@ -13,4 +13,4 @@ const getStore = () => {
|
|||
return store
|
||||
}
|
||||
|
||||
export default getStore
|
||||
export default getStore
|
||||
|
|
|
@ -3,4 +3,4 @@ const setTitle = (newTitle) => ({title}) => {
|
|||
return { title: newTitle }
|
||||
}
|
||||
|
||||
export default setTitle
|
||||
export default setTitle
|
||||
|
|
Loading…
Reference in a new issue