File tree Expand file tree Collapse file tree 2 files changed +29
-5
lines changed
Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Original file line number Diff line number Diff line change 11# Redux DevTools Counter example
22
3- ## Getting Started
3+ ## Running example
44
5- 1 . Install dependencies: ` npm i `
6- 2 . Start the development server: ` npm start `
5+ ```
6+ git clone https://github.com/gaearon/redux-devtools.git
7+ cd redux-devtools
8+ npm install
9+
10+ cd examples/counter
11+ npm install
12+ npm start
13+ open http://localhost:3000
14+ ```
Original file line number Diff line number Diff line change 1- export default function persistState ( sessionId ) {
1+ export default function persistState ( sessionId , deserializer = null ) {
22 if ( ! sessionId ) {
33 return next => ( ...args ) => next ( ...args ) ;
44 }
55
6+ function deserializeState ( fullState ) {
7+ if ( ! fullState || typeof deserializer !== 'function' ) {
8+ return fullState ;
9+ }
10+ return {
11+ ...fullState ,
12+ committedState : deserializer ( fullState . committedState ) ,
13+ computedStates : fullState . computedStates . map ( ( computedState ) => {
14+ return {
15+ ...computedState ,
16+ state : deserializer ( computedState . state )
17+ } ;
18+ } )
19+ } ;
20+ }
21+
622 return next => ( reducer , initialState ) => {
723 const key = `redux-dev-session-${ sessionId } ` ;
824
925 let finalInitialState ;
1026 try {
11- finalInitialState = JSON . parse ( localStorage . getItem ( key ) ) || initialState ;
27+ finalInitialState = deserializeState ( JSON . parse ( localStorage . getItem ( key ) ) ) || initialState ;
1228 next ( reducer , initialState ) ;
1329 } catch ( e ) {
1430 console . warn ( 'Could not read debug session from localStorage:' , e ) ;
You can’t perform that action at this time.
0 commit comments