简体   繁体   中英

unused expression, expected an assignment or function call

I am new to react. I am getting error on compile "unused expression, expected an assignment or function call" in the following code for button onClick.

handleClick = (itemClicked:PaymentTypes, e) => {
    <Route exact path="/ListSwipe" render={(props) =>  ( <ListSwipe vpType={itemClicked}/> )} />
}

I don't know your intention to use handleClick function to use like that but the warning ( It shouldn't be an error, maybe a linter error) you have because of you are neither returning anything nor invoking a function here. Try to use it like this:

handleClick = (itemClicked:PaymentTypes, e) =>
    <Route exact path="/ListSwipe" render={(props) =>  ( <ListSwipe vpType={itemClicked}/> )} />

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