0

So i wanted to learn react-redux with the help from tutorials by Wes Bos .

Everything was fine until i pushed to github and pulled into a remote server.

I thought it might be a node version issue. I was running on node ~v5 and the server was ~v6. So i changed back to v5 still got to issue.

import App from './components/app';
import Single from './components/Single';
import PhotoGrid from './components/PhotoGrid';

import { Router , Route , IndexRoute, browserHistory } from 'react-router';

import { Provider } from 'react-redux';
import store, { history } from './store';

const router = (
    <Provider store={store}>
        <Router history={history}>
            <Route path="/" component={App}>
                <IndexRoute component={PhotoGrid}></IndexRoute>
                <Route path="/view/:postId" component={Single}/>
            </Route>
        </Router>
    </Provider>
)
render(router,document.getElementById('root'));

So i get error "Unexpected token " for line 19 .

  18 | const router = (
> 19 |     <Provider store={store}>

I am not able to figure out what is the issue ? Is it issue with syntax or some libraries ? Any suggestion or help will be awesome.

Community
  • 1
  • 1
Sijan Shrestha
  • 2,136
  • 7
  • 26
  • 52
  • It looks like the environment on which you're running the code is not aware of JSX, try transpiling the code before running it. See http://stackoverflow.com/questions/33460420/babel-loader-jsx-syntaxerror-unexpected-token – Marco Scabbiolo Jul 03 '16 at 17:25
  • Possible duplicate of [babel-loader jsx SyntaxError: Unexpected token](http://stackoverflow.com/questions/33460420/babel-loader-jsx-syntaxerror-unexpected-token) – Marco Scabbiolo Jul 03 '16 at 17:29

1 Answers1

0

To anyone who is facing this issue and still not able to solve, for me the issue was a missing .babelrc file.

I just google and found and copy pasted in the same directory where your webpack config is.

So do not spin your head trying to figure out something is wrong with out code. Cheers.

Sijan Shrestha
  • 2,136
  • 7
  • 26
  • 52
  • just an empty file ? – conor909 Oct 29 '16 at 13:55
  • No I had the file missing because I got cloned it without the .babelrc file. – Sijan Shrestha Oct 29 '16 at 13:59
  • 2
    so what is the content of the .babelrc file that stops the error? – conor909 Oct 29 '16 at 14:01
  • The babelrc file helps define environment variable. When I tried to build , it could not fine the file which is the first thing that is looked up for transcompiling and since it could not find the file it showed the error as "unexpected token". Well it should have been more verbose instead of showing error on provider though. – Sijan Shrestha Oct 29 '16 at 14:06