user10398929
user10398929

Reputation:

unexpected token reactjs app on codesandbox

I am getting unexpected token on line 5 error on reactjs project when running it through codesandbox. The app works without an error when I run it on my local computer.

import React, { Component } from 'react';

import Header from '../Header/Header';
import Footer from '../Footer/Footer';

const App = ({ children }) => (
  <>
    <Header />

    <main>
      {children}
    </main>

    <Footer />
  </>
);

export default App;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>

Any suggestion why im getting that error

UPDATE

Here is the link to codesandbox

Upvotes: 0

Views: 673

Answers (1)

Jaisa Ram
Jaisa Ram

Reputation: 1767

React Fragments are a neat little feature that were released late last year with React v16.2.0. Try with updated react version:

<script src="https://unpkg.com/react/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script> 

as per react docs many tools don’t support it yet so you might want to explicitly write <React.Fragment> until the tooling catches up.

Upvotes: 1

Related Questions