Reputation: 1735
My react code contain input field,if I enters text in input field,the redux state updates and displays result in same component but I gets error with my dispatch function. My dispatch function unable to connect with the proper action function.
Please verify my Code
I have copied the code to CodeSandbox
https://codesandbox.io/s/peaceful-currying-hjwur?file=/src/App.js
Upvotes: 0
Views: 143
Reputation: 469
You're importing loginUser
into rootActions.js and renaming it to loginActions
, hence the confusion.
changing line 10 of Header.js to
dispatch(rootActions.loginAction(user_name));
will make it work as expected.
Upvotes: 1
Reputation: 342
The problem was with this call dispatch(rootAction.loginAction.loginUser(userName))
while rootAction has loginAction but loginAction is a function not an object with loginUser as it is default export.
Change it to dispatch(rootAction.loginAction(user_name));
and it should work.
Upvotes: 1