score:0
my guess is that you're trying to run that code without compiling it first. the es6 import/export syntax is still not natively supported in most environments - es6 modules have to be compiled to another format first, usually using babel.
score:0
this is improper syntax. you need to add the function keyword before the function signature, or define it as an arrow function like sam suggested.
i.e.
export default function (state = init_state, action) {...}
or export default (state = init_state, action) => {...}
, instead of export default (state = init_state, action) {...}
score:1
this happens when you have multiple exports on the same file and you add a default export to one of them , so the solution is either to export one module by using export default
or just export
if you want to export multiple objects , functions...etc in the same file
another thing to mention is the way you call a function , es6 introduces the arrow function
instead of this (arg1 , arg2 ){ .... }
you should do this (arg1 , arg2 ) => {.....}
so for your case
const init_state = [];
export (state = init_state, action) => {
switch(action.type) {
default: state
}
}
Source: stackoverflow.com
Related Query
- Uncaught SyntaxError: Unexpected token export
- Webpack - Uncaught SyntaxError: Unexpected token import with Redux
- Uncaught SyntaxError: Unexpected token export (Redux)
- React Js: Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
- babelify + browserify-rails + react, Uncaught SyntaxError: Unexpected token import
- react export Unexpected token
- React/Node Uncaught SyntaxError: Unexpected token <
- Fetching JSON returns error Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 and status code 304: Not Modified
- Uncaught SyntaxError: Unexpected token < in dist/index.html
- Uncaught SyntaxError: Unexpected token < in React JS
- Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
- Using Electron with Reactstrap causes error: Uncaught SyntaxError: Unexpected token :
- Uncaught SyntaxError: Unexpected token < reactjs react-pdf
- Uncaught SyntaxError: Unexpected token < with React
- SyntaxError: Unexpected token export when trying to use @babel/register
- Heroku create-react-app deploy Uncaught SyntaxError: Unexpected token <
- Learning ReactJS: Uncaught SyntaxError: Unexpected token import
- Uncaught SyntaxError: Unexpected token '<' React
- Webpack gzip bundle - Uncaught SyntaxError: Unexpected token <
- VM1661:1 Uncaught (in promise) SyntaxError: Unexpected token s in JSON at position 0
- How to export React component as npm package? Create-React-App SyntaxError: Unexpected token
- SyntaxError: Unexpected token export while running tests in Jest with components having amcharts4
- Import React in Node.js throws SyntaxError: Unexpected token export
- Uncaught SyntaxError: Unexpected token '<' | after "yarn add xlsx" | React Typescript
- Reactjs - Uncaught SyntaxError: Unexpected token <
- Webpack - Uncaught SyntaxError: Unexpected token import
- Uncaught SyntaxError: embedded: Unexpected token var Comment = React.createClass({...});
- Uncaught SyntaxError: Unexpected token '<' and ChunkLoadError: Loading chunk 16 failed
- babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/defineProperty.js:1 SyntaxError: Unexpected token export at createScript (vm.js:80:10
- React ES6 SystemJS - Uncaught (in promise) Error: Unexpected token <(…)
More Query from same tag
- Proper way to implement jwplayer in react component using webpack (react-starter-kit)
- React.JS : make fetch to populate select
- window.print() not applying the css while converting html to pdf
- Modal Textarea reloads with every click
- Display item details after clicking Link in React Router
- Authentication listeners when refactoring to React hooks
- React getting the ID of clicked button
- ReactJS: How to load SVG dynamically from an const object?
- Which life cycle method is preferred when using redux and react hooks?
- Property 'type' is missing in type 'AsyncThunkAction<Device, number, { dispatch: Dispatch<AnyAction>; }>' but required in type 'AnyAction'
- Reactjs Hook onChange with react-datepicker, invalid time value error
- Updating Reactive state by specific index changes array to object
- How can i pass the input text to the filter component in my React application
- React JS trying to return a Div
- Store it in a useRef Hook and keep the mutable value in the '.current' property
- How can i do this in Next Js
- Converting "class" into "react hooks"
- Conditional rendering decimal codes in JSX in React.js
- How to set modal scroll to top when it appears in React.js
- Passing props through NavLink
- Same constant is defined with GET but undefined with POST - express, mongo, react
- Firebase messaging is not supported in your browser how to solve this?
- How to insert public url from image stored in AWS S3 into JSX component?
- get data from child components to parents components in react js
- onBlur and onChange Influence each other
- Can I create class-based React Styled Components?
- How to convert this.state with index for React Hooks API
- changing state derived from props before render
- Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. (it does remove the elements from the dom but only once)
- How can I preserve a single query string value between routes in React Router?