简体   繁体   中英

es6 jsx syntax error using “`”

const { module } = this.props;

return(
    <div className="Card">
        <Link to=`/${module}/detail`></Link>
    </div>
 )

What's wrong with above syntax? I got error of JSX value should be either an expression or a quoted JSX text

When using javascript in JSX you need to wrap it in curly braces. The template literal you are using within the value of the to attribute on your Link component needs the curly braces.

return (
    <div className="Card">
        <Link to={`/${module}/detail`}></Link>
    </div>
 );

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