Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
4f59c951
N
next.js
项目概览
CoCo_Code_Op2
/
next.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
next.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4f59c951
编写于
5月 13, 2018
作者:
G
Gaston Fartek
提交者:
Tim Neutkens
5月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updating with-redux-saga example (#4356)
上级
af108228
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
54 addition
and
22 deletion
+54
-22
examples/with-redux-saga/package.json
examples/with-redux-saga/package.json
+6
-6
examples/with-redux-saga/pages/_app.js
examples/with-redux-saga/pages/_app.js
+31
-0
examples/with-redux-saga/pages/index.js
examples/with-redux-saga/pages/index.js
+6
-5
examples/with-redux-saga/pages/other.js
examples/with-redux-saga/pages/other.js
+5
-4
examples/with-redux-saga/store.js
examples/with-redux-saga/store.js
+6
-7
未找到文件。
examples/with-redux-saga/package.json
浏览文件 @
4f59c951
...
...
@@ -10,14 +10,14 @@
"dependencies"
:
{
"es6-promise"
:
"4.1.1"
,
"isomorphic-unfetch"
:
"2.0.0"
,
"next"
:
"
latest
"
,
"next-redux-saga"
:
"
1.0
.1"
,
"next-redux-wrapper"
:
"
1.2.0
"
,
"next"
:
"
6.0.1
"
,
"next-redux-saga"
:
"
3.0.0-beta
.1"
,
"next-redux-wrapper"
:
"
2.0.0-beta.6
"
,
"react"
:
"^16.0.0"
,
"react-dom"
:
"^16.0.0"
,
"react-redux"
:
"5.0.
5
"
,
"redux"
:
"
3.7.2
"
,
"redux-saga"
:
"0.1
5.4
"
"react-redux"
:
"5.0.
7
"
,
"redux"
:
"
4.0.0
"
,
"redux-saga"
:
"0.1
6.0
"
},
"devDependencies"
:
{
"redux-devtools-extension"
:
"2.13.2"
...
...
examples/with-redux-saga/pages/_app.js
0 → 100644
浏览文件 @
4f59c951
import
App
,
{
Container
}
from
'
next/app
'
import
React
from
'
react
'
import
{
Provider
}
from
'
react-redux
'
import
withRedux
from
'
next-redux-wrapper
'
import
createStore
from
'
../store
'
import
withReduxSaga
from
'
next-redux-saga
'
class
MyApp
extends
App
{
static
async
getInitialProps
({
Component
,
ctx
})
{
let
pageProps
=
{}
if
(
Component
.
getInitialProps
)
{
pageProps
=
await
Component
.
getInitialProps
({
ctx
})
}
return
{
pageProps
}
}
render
()
{
const
{
Component
,
pageProps
,
store
}
=
this
.
props
return
(
<
Container
>
<
Provider
store
=
{
store
}
>
<
Component
{...
pageProps
}
/
>
<
/Provider
>
<
/Container
>
)
}
}
export
default
withRedux
(
createStore
)(
withReduxSaga
({
async
:
true
})(
MyApp
))
examples/with-redux-saga/pages/index.js
浏览文件 @
4f59c951
import
React
from
'
react
'
import
{
connect
}
from
'
react-redux
'
import
{
increment
,
loadData
,
startClock
,
tickClock
}
from
'
../actions
'
import
{
withReduxSaga
}
from
'
../store
'
import
Page
from
'
../components/page
'
class
Counter
extends
React
.
Component
{
static
async
getInitialProps
({
store
,
isServer
})
{
store
.
dispatch
(
tickClock
(
isServer
))
static
async
getInitialProps
(
props
)
{
const
{
store
}
=
props
.
ctx
store
.
dispatch
(
tickClock
(
props
.
isServer
))
store
.
dispatch
(
increment
())
if
(
!
store
.
getState
().
placeholderData
)
{
store
.
dispatch
(
loadData
())
}
...
...
@@ -22,4 +23,4 @@ class Counter extends React.Component {
}
}
export
default
withReduxSaga
(
Counter
)
export
default
connect
()
(
Counter
)
examples/with-redux-saga/pages/other.js
浏览文件 @
4f59c951
import
React
from
'
react
'
import
{
connect
}
from
'
react-redux
'
import
{
increment
,
startClock
,
tickClock
}
from
'
../actions
'
import
{
withReduxSaga
}
from
'
../store
'
import
Page
from
'
../components/page
'
class
Counter
extends
React
.
Component
{
static
async
getInitialProps
({
store
,
isServer
})
{
static
async
getInitialProps
(
props
)
{
const
{
store
,
isServer
}
=
props
.
ctx
store
.
dispatch
(
tickClock
(
isServer
))
store
.
dispatch
(
increment
())
return
{
isServer
}
}
componentDidMount
()
{
...
...
@@ -19,4 +20,4 @@ class Counter extends React.Component {
}
}
export
default
withReduxSaga
(
Counter
)
export
default
connect
()
(
Counter
)
examples/with-redux-saga/store.js
浏览文件 @
4f59c951
import
{
createStore
,
applyMiddleware
}
from
'
redux
'
import
withRedux
from
'
next-redux-wrapper
'
import
nextReduxSaga
from
'
next-redux-saga
'
import
createSagaMiddleware
from
'
redux-saga
'
import
rootReducer
,
{
exampleInitialState
}
from
'
./reducer
'
import
rootSaga
from
'
./saga
'
...
...
@@ -23,10 +20,12 @@ export function configureStore (initialState = exampleInitialState) {
bindMiddleware
([
sagaMiddleware
])
)
store
.
sagaTask
=
sagaMiddleware
.
run
(
rootSaga
)
store
.
runSagaTask
=
()
=>
{
store
.
sagaTask
=
sagaMiddleware
.
run
(
rootSaga
)
}
store
.
runSagaTask
()
return
store
}
export
function
withReduxSaga
(
BaseComponent
)
{
return
withRedux
(
configureStore
)(
nextReduxSaga
(
BaseComponent
))
}
export
default
configureStore
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录