简体   繁体   中英

Expected an assignment or function call and instead saw an expression no-unused-expressions error in React

i am using React Router v4 in which i create a route file after creating a router path it gives a =n error as i mention of Expected an assignment or function call and instead saw an expression no-unused-expressions. i try my best to solve it but cannot as i am beginner in React that's why. Kindly solve this issue.

here is my code of router.js file.

import React, {Component} from 'react';
import {
    BrowserRouter as Router,
    Route,
    Link

} from 'react-router-dom';
import App from '../App';

const CustomRoute = () => {

    <Router> 
               <Route path="/" component={App} />

       </Router> 
}

export default CustomRoute;

Function component should return a value and it doesn't. Linter error reflects that.

It should be either:

const CustomRoute = () => {
    return <Router> 
           <Route path="/" component={App} />
    </Router> 
}

Or:

const CustomRoute = () => (
    <Router> 
           <Route path="/" component={App} />
    </Router> 
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM