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
7a1724f3
Unverified
Commit
7a1724f3
authored
May 31, 2020
by
Luis Alvarez D
Committed by
GitHub
May 31, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Examples] Remove unused file from with-redux (#13570)
Leftover from a past PR
parent
48c84400
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
48 deletions
+0
-48
redux.js
examples/with-redux/lib/redux.js
+0
-48
No files found.
examples/with-redux/lib/redux.js
deleted
100644 → 0
View file @
48c84400
import
{
Provider
}
from
'react-redux'
import
{
initializeStore
}
from
'../store'
import
App
from
'next/app'
export
const
withRedux
=
(
PageComponent
)
=>
{
const
WithRedux
=
({
initialReduxState
,
...
props
})
=>
{
const
store
=
initializeClientSideStore
(
initialReduxState
)
return
(
<
Provider
store
=
{
store
}
>
<
PageComponent
{...
props
}
/
>
<
/Provider
>
)
}
// Make sure people don't use this HOC on _app.js level
if
(
process
.
env
.
NODE_ENV
!==
'production'
)
{
const
isAppHoc
=
PageComponent
===
App
||
PageComponent
.
prototype
instanceof
App
if
(
isAppHoc
)
{
throw
new
Error
(
'The withRedux HOC only works with PageComponents'
)
}
}
// Set the correct displayName in development
if
(
process
.
env
.
NODE_ENV
!==
'production'
)
{
const
displayName
=
PageComponent
.
displayName
||
PageComponent
.
name
||
'Component'
WithRedux
.
displayName
=
`withRedux(
${
displayName
}
)`
}
return
WithRedux
}
let
reduxStore
export
const
initializeServerSideStore
=
(
initialState
)
=>
{
// Always make a new store if server ('getStaticProps' or 'getServerSideProps'), to avoid sharing the state between requests.
// Check ssg.js and ssr.js pages for usage
return
initializeStore
(
initialState
)
}
export
const
initializeClientSideStore
=
(
initialState
)
=>
{
// Create store if unavailable on the client and set it on the window object
if
(
!
reduxStore
)
{
reduxStore
=
initializeStore
(
initialState
)
}
return
reduxStore
}
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