Giter VIP home page Giter VIP logo

examples-redux-persist-next's People

Contributors

nickmarca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

examples-redux-persist-next's Issues

Create with _app and document

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

need help on create reducer

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.