No Redux tools when server side rendering using nextjs
I have been using nextjs / reduxSaga / expressJs to create a simple todo app. I have a problem when rendering my app using my nodejs server, my redux tools do not work but action are getting dispatched normaly.
I say "when i use my nodejs server" because when using the test server provided by nextjs everything seems to work just right.
Store code :
import {createStore, applyMiddleware, compose} from 'redux'
import createSagaMiddleware from 'redux-saga'
import taskReducer from './reducers/tasks'
import {watchFetchTask} from './sagas'
const sagaMiddleware = createSagaMiddleware()
const bindMiddleware = (middleware) => {
if (process.env.NODE_ENV !== 'production') {
const { composeWithDevTools } = require('redux-devtools-extension')
return composeWithDevTools(applyMiddleware(...middleware))
}
return applyMiddleware(...middleware)
}
function configureStore () {
const store = createStore(
taskReducer,
bindMiddleware([sagaMiddleware])
)
store.runSagaTask = () => {
store.sagaTask = sagaMiddleware.run(watchFetchTask)
}
store.runSagaTask()
return store
}
export default configureStore
Nodejs serving code :
exports.index = (req, res) => {
handle(req, res)
}
where handle is :
const dev = process.env.NODE_ENV !== 'production'
const nextapp = next({dev})
const handle = nextapp.getRequestHandler()
I do not see how can this work since the bindMiddleware is triggered on the server. How can i make it work with my nodejs server ?
react-redux redux-saga next.js
add a comment |
I have been using nextjs / reduxSaga / expressJs to create a simple todo app. I have a problem when rendering my app using my nodejs server, my redux tools do not work but action are getting dispatched normaly.
I say "when i use my nodejs server" because when using the test server provided by nextjs everything seems to work just right.
Store code :
import {createStore, applyMiddleware, compose} from 'redux'
import createSagaMiddleware from 'redux-saga'
import taskReducer from './reducers/tasks'
import {watchFetchTask} from './sagas'
const sagaMiddleware = createSagaMiddleware()
const bindMiddleware = (middleware) => {
if (process.env.NODE_ENV !== 'production') {
const { composeWithDevTools } = require('redux-devtools-extension')
return composeWithDevTools(applyMiddleware(...middleware))
}
return applyMiddleware(...middleware)
}
function configureStore () {
const store = createStore(
taskReducer,
bindMiddleware([sagaMiddleware])
)
store.runSagaTask = () => {
store.sagaTask = sagaMiddleware.run(watchFetchTask)
}
store.runSagaTask()
return store
}
export default configureStore
Nodejs serving code :
exports.index = (req, res) => {
handle(req, res)
}
where handle is :
const dev = process.env.NODE_ENV !== 'production'
const nextapp = next({dev})
const handle = nextapp.getRequestHandler()
I do not see how can this work since the bindMiddleware is triggered on the server. How can i make it work with my nodejs server ?
react-redux redux-saga next.js
add a comment |
I have been using nextjs / reduxSaga / expressJs to create a simple todo app. I have a problem when rendering my app using my nodejs server, my redux tools do not work but action are getting dispatched normaly.
I say "when i use my nodejs server" because when using the test server provided by nextjs everything seems to work just right.
Store code :
import {createStore, applyMiddleware, compose} from 'redux'
import createSagaMiddleware from 'redux-saga'
import taskReducer from './reducers/tasks'
import {watchFetchTask} from './sagas'
const sagaMiddleware = createSagaMiddleware()
const bindMiddleware = (middleware) => {
if (process.env.NODE_ENV !== 'production') {
const { composeWithDevTools } = require('redux-devtools-extension')
return composeWithDevTools(applyMiddleware(...middleware))
}
return applyMiddleware(...middleware)
}
function configureStore () {
const store = createStore(
taskReducer,
bindMiddleware([sagaMiddleware])
)
store.runSagaTask = () => {
store.sagaTask = sagaMiddleware.run(watchFetchTask)
}
store.runSagaTask()
return store
}
export default configureStore
Nodejs serving code :
exports.index = (req, res) => {
handle(req, res)
}
where handle is :
const dev = process.env.NODE_ENV !== 'production'
const nextapp = next({dev})
const handle = nextapp.getRequestHandler()
I do not see how can this work since the bindMiddleware is triggered on the server. How can i make it work with my nodejs server ?
react-redux redux-saga next.js
I have been using nextjs / reduxSaga / expressJs to create a simple todo app. I have a problem when rendering my app using my nodejs server, my redux tools do not work but action are getting dispatched normaly.
I say "when i use my nodejs server" because when using the test server provided by nextjs everything seems to work just right.
Store code :
import {createStore, applyMiddleware, compose} from 'redux'
import createSagaMiddleware from 'redux-saga'
import taskReducer from './reducers/tasks'
import {watchFetchTask} from './sagas'
const sagaMiddleware = createSagaMiddleware()
const bindMiddleware = (middleware) => {
if (process.env.NODE_ENV !== 'production') {
const { composeWithDevTools } = require('redux-devtools-extension')
return composeWithDevTools(applyMiddleware(...middleware))
}
return applyMiddleware(...middleware)
}
function configureStore () {
const store = createStore(
taskReducer,
bindMiddleware([sagaMiddleware])
)
store.runSagaTask = () => {
store.sagaTask = sagaMiddleware.run(watchFetchTask)
}
store.runSagaTask()
return store
}
export default configureStore
Nodejs serving code :
exports.index = (req, res) => {
handle(req, res)
}
where handle is :
const dev = process.env.NODE_ENV !== 'production'
const nextapp = next({dev})
const handle = nextapp.getRequestHandler()
I do not see how can this work since the bindMiddleware is triggered on the server. How can i make it work with my nodejs server ?
react-redux redux-saga next.js
react-redux redux-saga next.js
asked Nov 19 '18 at 17:43


TyLogosTyLogos
11
11
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53380027%2fno-redux-tools-when-server-side-rendering-using-nextjs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53380027%2fno-redux-tools-when-server-side-rendering-using-nextjs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown