Posts

Showing posts with the label react-redux

SyntaxError: Unexpected token ' { ' while starting the reactjs app in my terminal [duplicate]

SyntaxError: Unexpected token ' { ' while starting the reactjs app in my terminal [duplicate] This question already has an answer here: I tried to run existing clone reactjs app, the following error is accured in terminal, SyntaxError: Unexpected token { at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:374:25) at Object.Module._extensions..js (module.js:417:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Function.Module.runMain (module.js:442:10) at startup (node.js:136:18) at node.js:966:3 Here my start.js coding from (myappname)/node_modules/react-scripts/scripts/start.js:31 start.js (myappname)/node_modules/react-scripts/scripts/start.js:31 const { choosePort, createCompiler, prepareProxy, prepareUrls, } = require('react-dev-utils/WebpackDevServerUtils'); Then how to solve this problem? This question has been asked before and already has an answer. If those answers do not fully addre...

Wrapping Provider in same component throws Element type is invalid: expected a string (for built-in components) or a class/function but got: object

Wrapping Provider in same component throws Element type is invalid: expected a string (for built-in components) or a class/function but got: object I wrote a simple counter example in both Mobx & Redux & it works Full demo is available https://codesandbox.io/s/nw303w6jxl But if I remove Provider from ./src/index.js Provider ./src/index.js const App = () => ( ); & put it in ./src/redux.js while default exporting it throws an error ./src/redux.js export default ( <Provider store={store}> <ConnectReduxApp /> </Provider> ); Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function but got: object Its working but I don't know why its happening? I checked the typeof the default exported function from ./src/redux.js ,i.e, typeof ./src/redux.js console.log( typeof( <Provider store={store}> <ConnectReduxApp /> ...

Redux action is working but reducer is not

Redux action is working but reducer is not Not sure why my reducer is not working. I have a console.log in my actions file. So for example, when I test out a failed login attempt, I see the console log in both the loginFromAPI function and loginFailure function (see in actions.js below) . These are outputting what is expected. But for some reason, the login reducer is not working. When I console.log in the loginReducer.js , I see nothing. This tells me that although the action is working, the reducer is not. My redux props do not change from the initial state (I've checked this by outputting to the console). I'd appreciate any help solving this issue. Here is the file structure: app reducers loginReducer.js rootReducer.js screens Login Login.js index.js actions.js store configureStore.js App.js actionTypes.js File configureStore.js configureStore.js import { createStore, applyMiddleware } from 'redux'; import a...