Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
9ba7a10f
Commit
9ba7a10f
authored
Feb 21, 2017
by
Tim Neutkens
Committed by
GitHub
Feb 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix linting errors (#1235)
parent
7d4d7095
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
15 additions
and
19 deletions
+15
-19
getStore.js
examples/with-refnux/helpers/getStore.js
+2
-2
withRefnux.js
examples/with-refnux/helpers/withRefnux.js
+3
-6
page1.js
examples/with-refnux/pages/page1.js
+2
-2
page2.js
examples/with-refnux/pages/page2.js
+2
-3
counterIncrement.js
examples/with-refnux/store/counterIncrement.js
+1
-1
getInitialState.js
examples/with-refnux/store/getInitialState.js
+2
-2
getStore.js
examples/with-refnux/store/getStore.js
+2
-2
setTitle.js
examples/with-refnux/store/setTitle.js
+1
-1
No files found.
examples/with-refnux/helpers/getStore.js
View file @
9ba7a10f
...
@@ -4,7 +4,7 @@ let storeMemoized = null
...
@@ -4,7 +4,7 @@ let storeMemoized = null
const
getStore
=
(
initialState
)
=>
{
const
getStore
=
(
initialState
)
=>
{
let
store
=
null
let
store
=
null
if
(
typeof
window
==
'undefined'
)
{
if
(
typeof
window
==
=
'undefined'
)
{
store
=
createStore
(
initialState
)
store
=
createStore
(
initialState
)
}
else
{
}
else
{
if
(
!
storeMemoized
)
{
if
(
!
storeMemoized
)
{
...
@@ -15,4 +15,4 @@ const getStore = (initialState) => {
...
@@ -15,4 +15,4 @@ const getStore = (initialState) => {
return
store
return
store
}
}
export
default
getStore
export
default
getStore
\ No newline at end of file
examples/with-refnux/helpers/withRefnux.js
View file @
9ba7a10f
import
{
Provider
}
from
'refnux'
import
{
Provider
}
from
'refnux'
import
getStore
from
'./getStore'
import
getStore
from
'./getStore'
// The `withRefnux` "decorator"
// The `withRefnux` "decorator"
...
@@ -9,12 +8,11 @@ import getStore from './getStore'
...
@@ -9,12 +8,11 @@ import getStore from './getStore'
// - passes `store` to Component's `getInitialProps` so that it can dispatch actions
// - passes `store` to Component's `getInitialProps` so that it can dispatch actions
const
withRefnux
=
(
getInitialState
,
Component
)
=>
{
const
withRefnux
=
(
getInitialState
,
Component
)
=>
{
const
Wrapper
=
(
props
)
=>
{
const
Wrapper
=
(
props
)
=>
{
var
store
=
props
.
store
var
store
=
props
.
store
// if getInitialProps was executed on the server we get a store
// if getInitialProps was executed on the server we get a store
// that's missing non-serializable functions.
// 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.
// state coming from the server.
if
(
!
store
.
dispatch
)
{
if
(
!
store
.
dispatch
)
{
store
=
getStore
(
props
.
store
.
state
)
store
=
getStore
(
props
.
store
.
state
)
...
@@ -38,5 +36,4 @@ const withRefnux = (getInitialState, Component) => {
...
@@ -38,5 +36,4 @@ const withRefnux = (getInitialState, Component) => {
return
Wrapper
return
Wrapper
}
}
export
default
withRefnux
export
default
withRefnux
\ No newline at end of file
examples/with-refnux/pages/page1.js
View file @
9ba7a10f
...
@@ -14,7 +14,7 @@ const Page1 = connect(
...
@@ -14,7 +14,7 @@ const Page1 = connect(
<
h3
>
{
state
.
title
}
<
/h3
>
<
h3
>
{
state
.
title
}
<
/h3
>
<
p
>
Current
state
:
{
JSON
.
stringify
(
state
,
null
,
2
)}
<
/p
>
<
p
>
Current
state
:
{
JSON
.
stringify
(
state
,
null
,
2
)}
<
/p
>
<
button
onClick
=
{()
=>
dispatch
(
counterIncrement
)}
>
Increment
<
/button
>
<
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
>
<
/div
>
)
)
...
@@ -25,4 +25,4 @@ Page1.getInitialProps = async function (context) {
...
@@ -25,4 +25,4 @@ Page1.getInitialProps = async function (context) {
return
{}
// we have a store, we don't need props!
return
{}
// we have a store, we don't need props!
}
}
export
default
withRefnux
(
getInitialState
,
Page1
)
export
default
withRefnux
(
getInitialState
,
Page1
)
\ No newline at end of file
examples/with-refnux/pages/page2.js
View file @
9ba7a10f
...
@@ -14,7 +14,7 @@ const Page2 = connect(
...
@@ -14,7 +14,7 @@ const Page2 = connect(
<
h3
>
{
state
.
title
}
<
/h3
>
<
h3
>
{
state
.
title
}
<
/h3
>
<
p
>
Current
state
:
{
JSON
.
stringify
(
state
,
null
,
2
)}
<
/p
>
<
p
>
Current
state
:
{
JSON
.
stringify
(
state
,
null
,
2
)}
<
/p
>
<
button
onClick
=
{()
=>
dispatch
(
counterIncrement
)}
>
Increment
<
/button
>
<
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
>
<
/div
>
)
)
...
@@ -24,5 +24,4 @@ Page2.getInitialProps = async function (context) {
...
@@ -24,5 +24,4 @@ Page2.getInitialProps = async function (context) {
return
{}
return
{}
}
}
export
default
withRefnux
(
getInitialState
,
Page2
)
export
default
withRefnux
(
getInitialState
,
Page2
)
\ No newline at end of file
examples/with-refnux/store/counterIncrement.js
View file @
9ba7a10f
...
@@ -3,4 +3,4 @@ const counterIncrement = ({counter}, dispatch) => {
...
@@ -3,4 +3,4 @@ const counterIncrement = ({counter}, dispatch) => {
return
{
counter
:
counter
+
1
}
return
{
counter
:
counter
+
1
}
}
}
export
default
counterIncrement
export
default
counterIncrement
\ No newline at end of file
examples/with-refnux/store/getInitialState.js
View file @
9ba7a10f
...
@@ -3,6 +3,6 @@ const getInitialState = () => {
...
@@ -3,6 +3,6 @@ const getInitialState = () => {
title
:
''
,
title
:
''
,
counter
:
0
counter
:
0
}
}
}
}
export
default
getInitialState
export
default
getInitialState
\ No newline at end of file
examples/with-refnux/store/getStore.js
View file @
9ba7a10f
...
@@ -4,7 +4,7 @@ const storeInitialState = { counter: 0, key: 'value' }
...
@@ -4,7 +4,7 @@ const storeInitialState = { counter: 0, key: 'value' }
const
getStore
=
()
=>
{
const
getStore
=
()
=>
{
let
store
=
null
let
store
=
null
if
(
typeof
window
==
'undefined'
)
{
if
(
typeof
window
==
=
'undefined'
)
{
store
=
createStore
(
storeInitialState
)
store
=
createStore
(
storeInitialState
)
}
else
{
}
else
{
store
=
window
.
store
||
createStore
(
storeInitialState
)
store
=
window
.
store
||
createStore
(
storeInitialState
)
...
@@ -13,4 +13,4 @@ const getStore = () => {
...
@@ -13,4 +13,4 @@ const getStore = () => {
return
store
return
store
}
}
export
default
getStore
export
default
getStore
\ No newline at end of file
examples/with-refnux/store/setTitle.js
View file @
9ba7a10f
...
@@ -3,4 +3,4 @@ const setTitle = (newTitle) => ({title}) => {
...
@@ -3,4 +3,4 @@ const setTitle = (newTitle) => ({title}) => {
return
{
title
:
newTitle
}
return
{
title
:
newTitle
}
}
}
export
default
setTitle
export
default
setTitle
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment