sbalay / react-native-redux-toast

Simple to use, easy to customize Toast component for Android & iOS. Developed with love for redux apps
50 stars 21 forks source link

TypeError: stat merge is not a function #14

Open isAlmogK opened 6 years ago

isAlmogK commented 6 years ago

I'm getting the following error:

screen shot 2018-01-25 at 1 42 21 pm

Here is my code it's pretty much like the example Reducer Index

import { combineReducers } from 'redux';

// Import reducers
import routesReducer from './routesReducer';
import { reducer as navbarReducer } from './navbarReducers';
import { reducer as projectsReducer } from './projectsReducers';
import { reducer as teamsReducer } from './teamsReducers';
import { reducer as photosReducer } from './photosReducers';
import { reducer as photosCommentsReducer } from './photosCommentsReducers';
import { reducer as persistReducer } from './persistReducers';
import { reducer as connectionReducer } from './connectionReducers';
import { reducer as newDataReducer } from './newDataReducers';
import { reducer as functionReducer } from './functionsReducers';
import { reducer as userReducer } from './userReducers';
import { reducer as jwtReducer } from './jwtReducer';
import { reducer as resetPasswordReducer } from './resetPasswordReducer';
import { toastReducer as toast } from 'react-native-redux-toast';

export default combineReducers({
    //Scenes,
    toast,
    routesReducer,
    persist: persistReducer,
    connectionStatus:connectionReducer,
    navbar: navbarReducer,
    selectedProject: projectsReducer,
    selectedTeam: teamsReducer,
    selectedTeamPhotos: photosReducer,
    photosComments: photosCommentsReducer,
    newData: newDataReducer,
    functions:functionReducer,
    user:userReducer,
    jwt:jwtReducer,
    resetPassword:resetPasswordReducer,
});

Calling the props

// Maps to props
const mapDispatchToProps = (dispatch) => {
    return {
        postEditComment: (data) => dispatch(photosCommentsActionCreators.photoEditComment(data)),
        testing:() => dispatch(ToastActionsCreators.displayError('Error toast!'))

        //this.props.dispatch(ToastActionsCreators.displayError('Error toast!'));
    };
};
jordanmkoncz commented 6 years ago

Getting the same problem. I think this library is making the assumption that the state is set up using ImmutableJS, resulting in this error when you are actually not using ImmutableJS.

jan-happy commented 5 years ago

I have the same problem.

delusionxb commented 5 years ago

I think this https://github.com/reactjs/react-router-redux/issues/441 would help you. Several things you need to update:

  1. import { combineReducers } from 'redux-immutable'; // not from 'redux'
  2. import { fromJS } from 'immutable' and convert the initialState to immutable object with fromJS()
  3. also call fromJS() each time you update state
  4. call state.get(reducerName) each time you need to get values, don't use 'state.key', I suggest you write your own util to handle conversion
PeterChauYEG commented 5 years ago

I've forked this and removed redux-immutable. Here's a link for anyone that runs into this issue: https://github.com/PeterChauYEG/react-native-redux-toast