reactjs - Store does not have a valid reducer. react redux -


i'm having problem above, tried this, no luck.

here's store:

import { compose, combinereducers, applymiddleware, createstore } "redux"; import thunkmiddleware "redux-thunk"; import * activities "../reducers/activities"; import * location "../reducers/location";  const configurestore = railsprops => {   const composedstore = compose(     applymiddleware(thunkmiddleware),     window.__redux_devtools_extension__ && window.__redux_devtools_extension__()   );    const combinedreducers = combinereducers({     location,     activities   });   return composedstore(createstore)(combinedreducers, railsprops); };  export default configurestore; 

here's location reducer:

import { combinereducers } "redux"; import * actions "../constants/constants";  const coordinates = (state = {}, action) => {   switch (action.type) {     case actions.get_location_success:     case actions.get_location_request:     case actions.get_location_failure:     default:       return state;   } };  const reducer = coordinates;  export default reducer; 

here's activities reducer:

import { combinereducers } "redux"; import * actions "../constants/constants";  const page = (state = 0, action) => {   switch (action.type) {     case actions.next_activity_page:       return action.page < action.totalpages - 1         ? action.page + 1         : action.page;     case actions.prev_activity_page:       return action.page > 0 ? action.page - 1 : 0;     default:       return state;   } };  const activities = (state = {}, action) => {   switch (action.type) {     case actions.fetch_activities_success: {       return state.concat(action.activities);     }     case actions.fetch_activities_request:      case actions.fetch_activities_failure:      default:       return state;   } };  const reducer = combinereducers({ page, activities });  export default reducer; 

i guess has combinereducers method , how import stuff, i'm not sure what's wrong there.

thanks

this wrong:

import * activities "../reducers/activities"; import * location "../reducers/location"; 

above export named exports file while reducers default exports.

correct:

import activities "../reducers/activities"; import location "../reducers/location"; 

edit:

if want export reducers file make them named:

export const page = (state = 0, action) => {   switch (action.type) {     ...   } };  export const activities = (state = {}, action) => {   switch (action.type) {     ...   } }; 

and later:

import { page, activities } 'path/to/file.js'; 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -