jk-gan / redux-flipper

Redux middleware for React Native for Flipper
MIT License
159 stars 21 forks source link

TypeError: JSON.stringify cannot serialize cyclic structures #14

Closed wrightmk closed 4 years ago

wrightmk commented 4 years ago

"react-native": "0.62.0" "redux-flipper": "^1.0.0" "react-native-flipper": "^0.39.0"

I've downloaded and integrated the extension into my app, but it breaks on refresh. When I run my app and then open flipper, I'm able to use the redux debugger. However, once I refresh my app, I get TypeError: JSON.stringify cannot serialize cyclic structures.

jk-gan commented 4 years ago

Can you provide some sample codes to reproduce?

felippepuhle commented 4 years ago

same here.. tried a bunch of things and it's not working

  const reducers = require('./reducers').default
  const middlewares = [thunk]

  if (__DEV__) {
    const createDebugger = require('redux-flipper').default
    middlewares.push(createDebugger())
  }

  store = createStore(
    persistReducer(
      {
        storage: AsyncStorage,
        key: 'xxx',
        whitelist: ['x', 'y'],
      },
      reducers
    ),
    initialState,
    applyMiddleware(...middlewares)
  )
msadura commented 4 years ago

Same issue here. Seems like this happens when you add more than 1 middleware to applyMiddleware and because of that plugin seems to be unusable at the moment :( In my cane I am using redux-observable but I tried different middlewares and result is the same. It works only when reduxDebugger is the only middleware.

const epicMiddleware = createEpicMiddleware();
let middleware;
if (__DEV__) {
  const createDebugger = require('redux-flipper').default;

  const reduxDebugger = createDebugger();
  middleware = applyMiddleware(epicMiddleware, reduxDebugger);
} else {
  middleware = applyMiddleware(epicMiddleware);
}

export default function configureStore(initialState = defaultState): Store {
  const store = createStore(rootReducer, initialState, middleware);
  epicMiddleware.run(rootEpic);
  return store;
}

"react-native": "0.62.2" "redux-flipper": "^1.0.0" "react-native-flipper": "^0.42.0"

plwai commented 4 years ago

@msadura I have tried to install redux-observable and applied the middleware. It works fine for me. Perhaps, your store data structures have cyclic reference value which causing the error. Currently, Flipper API does not support Cyclic Reference in JSON. We will roll out a patch to solve this issue soon.

msadura commented 4 years ago

@plwai you are probably right. Raw redux-observable middleware without data works as expected. Thx for the update, I will observe https://github.com/jk-gan/flipper-plugin-redux-debugger/issues/13