Mian Munib
Mian Munib

Reputation: 1

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;

Upvotes: 0

Views: 4606

Answers (1)

Estus Flask
Estus Flask

Reputation: 222319

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> 
)

Upvotes: 2

Related Questions