react: next-redux-saga
instead of using the Provider component, you can use the withRedux higher order component to inject the store initialization functionality.
import withRedux from 'next-redux-wrapper';
import initializeStore from './path/to/store'; const HomePage = () =>
<div>
That's the home page.
</div> export default withRedux(initializeStore)(HomePage);
Basically, in a server-side rendered React application with Next.js, you can exchange the Providercomponent from react-redux with withRedux from next-redux-wrapper. You can use it for every entry point in your pages/ directory.
In your child components, you can still use the connect higher order component from react-redux to make your Redux store accessible with mapStateToProps and mapDispatchToProps. It works the same as before.
Redux Saga + Next.js
Last but not least, I had the requirement to use Redux Saga for asynchronous Redux actions in my Next.js application. The basic Redux Saga middleware lookup when creating a Redux store looks similar to this
import createSagaMiddleware from 'redux-saga'; import rootSaga from 'path/to/combined/sagas';
import rootReducer from 'path/to/combined/reducers'; const saga = createSagaMiddleware(); const initializeStore = initialState => {
const store = createStore(
rootReducer,
initialState,
applyMiddleware(saga)
); saga.run(rootSaga); return store;
}; export default initializeStore;
react: next-redux-saga的更多相关文章
- react native redux saga增加日志功能
redux-logger地址:https://github.com/evgenyrodionov/redux-logger 目前Reac native项目中已经使用redux功能,异步中间件使用red ...
- [React] 14 - Redux: Redux Saga
Ref: Build Real App with React #14: Redux Saga Ref: 聊一聊 redux 异步流之 redux-saga [入门] Ref: 从redux-thun ...
- react系列(六)Redux Saga
在Redux中常要管理异步操作,目前社区流行的有Redux-Saga.Redux-thunk等.在管理复杂应用时,推荐使用Redux-Saga,它提供了用 generator 书写类同步代码的能力. ...
- 实例讲解react+react-router+redux
前言 总括: 本文采用react+redux+react-router+less+es6+webpack,以实现一个简易备忘录(todolist)为例尽可能全面的讲述使用react全家桶实现一个完整应 ...
- 基于 React.js + Redux + Bootstrap 的 Ruby China 示例 (转)
一直学 REACT + METEOR 但路由部分有点问题,参考一下:基于 React.js + Redux + Bootstrap 的 Ruby China 示例 http://react-china ...
- 基于react+react-router+redux+socket.io+koa开发一个聊天室
最近练手开发了一个项目,是一个聊天室应用.项目虽不大,但是使用到了react, react-router, redux, socket.io,后端开发使用了koa,算是一个比较综合性的案例,很多概念和 ...
- 最新的chart 聊天功能( webpack2 + react + router + redux + scss + nodejs + express + mysql + es6/7)
请表明转载链接: 我是一个喜欢捣腾的人,没事总喜欢学点新东西,可能现在用不到,但是不保证下一刻用不到. 我一直从事的是依赖angular.js 的web开发,但是我怎么能一直用它呢?看看最近火的一塌糊 ...
- 【前端】react and redux教程学习实践,浅显易懂的实践学习方法。
前言 前几天,我在博文[前端]一步一步使用webpack+react+scss脚手架重构项目 中搭建了一个react开发环境.然而在实际的开发过程中,或者是在对源码的理解中,感受到react中用的最多 ...
- 【前端,干货】react and redux教程学习实践(二)。
前言 这篇博文接 [前端]react and redux教程学习实践,浅显易懂的实践学习方法. ,上一篇简略的做了一个redux的初级demo,今天深入的学习了一些新的.有用的,可以在生产项目中使用的 ...
- [React] 15 - Redux: practice IM
本篇属于私人笔记. client 引导部分 一.assets: 音频,图片,字体 ├── assets │ ├── audios │ ├── fonts │ └── images 二.main&quo ...
随机推荐
- Ubuntu学习笔记3-图书知识点总结
免费的虚拟机软件:vmware server Ubuntu下切换到root用户: 1,su 2, sudo -s 3, sudo+命令 Ubuntu下切换到一般用户: su chennan 软件包的安 ...
- 模板继承(extend)——(Day68)
模板继承 (extend) Django模版引擎中最强大也是最复杂的部分就是模版继承了.模版继承可以让您创建一个基本的“骨架”模版,它包含您站点中的全部元素,并且可以定义能够被子模版覆盖的 block ...
- shiro配置
web.xml <!-- Shiro Filter is defined in the spring application context: --> <!-- 1. 配置 Shir ...
- slf4j-api、slf4j-log4j12以及log4j之间什么关系?
几乎在每个jar包里都可以看到log4j的身影,在多个子工程构成项目中,slf4j相关的冲突时不时就跳出来让你不爽,那么slf4j-api.slf4j-log4j12还有log4j他们是什么关系?我把 ...
- ES集群重启
操作步骤: 1. Disable shard allocation curl -XPUT 'localhost:9200/_cluster/settings?pretty' -d '{ " ...
- html 基础 超链接
***设置超链接的样式示例 a:link 超链接被点前状态 a:visited 超链接点击后状态 a:hover 悬停在超链接时 a:active 点击超链接时 在定义这些状态时,有一个顺序l v ...
- Firebug入门指南(转)
本文转自:http://www.ruanyifeng.com/blog/2008/06/firebug_tutorial.html 作者: 阮一峰 日期: 2008年6月 8日 据说,对于网页开发人员 ...
- json字符串转化为json对象and 对象转化为 json字符串
第一种方法: var data =evel('('+jsonstr+')') 解析: 这种方法是常用的方法, 即动态执行 javascript代码 在堆中存放数据. 存在安全问题. 第二种方法: ...
- 运行报警告UserWarning: Unknown extension is not supported and will be removed warn(msg)
运行python代码,出现如下警告: C:\Users\niko\PycharmProjects\python_new\venv\lib\site-packages\openpyxl\reader\w ...
- python3:利用smtplib库和smtp.qq.com邮件服务器发送邮件
python3:利用smtplib库和smtp.qq.com邮件服务器发送邮件 使用qq的邮件服务器需要注意的两个地方主要是: 1.协议问题 使用465端口 SSL 协议 2.口令问题 出现SMTPA ...