nickmarca / examples-redux-persist-next Goto Github PK
View Code? Open in Web Editor NEWThis is an example how you can use NextJS v4 with reduxPersist v5
This is an example how you can use NextJS v4 with reduxPersist v5
Hi there, first of all, thanks by the example.
I could implement without _app.js and _document.js with success.
But I can't with them... would you create an example with _document.js and _app.js new version?
Thanks in advance
Carlos Vieira
HI there sorry bother you....
Hi there
I'm following this example of element6
rt2zz/redux-persist#598
and I need help in creating the ./reducer in order to save information in user..
I already have in this.props the user and dispatch... but I need help...
sorry if I'm taking to much from you but I really need this ./reducer rootreducer
let _persistor;
export default Page => withRedux(
(initialState, { isServer }) => {
const { persistor, store } = makeStore(initialState, { isServer })
_persistor = persistor
return store
}, mapStateToProps, mapDispatchToProps
)(class DefaultPage extends React.Component {
render() {
if (!_persistor) return <Loading/>
return (
<PersistGate loading={<Loading/>} persistor={_persistor}>
<App />
</PersistGate>
)
}
}
//store.js
import { createStore } from "redux";
import rootReducer from "./reducer";
import storage from 'redux-persist/lib/storage'
function clientStore(initialState) {
const { persistStore, persistReducer } = require('redux-persist')
const persistConfig = {
key: 'root',
storage,
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
const store = createStore(persistedReducer, initialState)
const persistor = persistStore(store)
return { store, persistor }
}
export const makeStore = (initialState, { isServer }) => {
const { store, persistor } = isServer ? { store: createStore(rootReducer, initialState) } : clientStore(initialState);
if (module.hot) {
module.hot.accept('./reducer', () => {
console.log('Replacing reducer');
store.replaceReducer(require('./reducer').default);
});
}
return { store, persistor };
};
thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.