Home > Back-end >  unexpected string concatenation of literals react.js
unexpected string concatenation of literals react.js

Time:10-25

 to={routeName.tutorClassView   '?classId='   `${_.get(value, '_id')}`}

 to={routeName.tutorClassView   '?classId='   `${_.get(v, 'id')}`   '&providerId='   `${_.get(v, 'provider.id')}`}

What am i doing wrong here

CodePudding user response:

You can use template string literal like this

to={`routeName.tutorClassView?classId=${_.get(value, '_id')}`}

CodePudding user response:

you can entirely make use of template literals as below

to = `${routeName.tutorClassView}?classId=${_.get(value, "_id")}`;

to = `${routeName.tutorClassView}?classId=${_.get(v, "id")}&providerId=${_.get(
  v,
  "provider.id"
)}`;

with curly braces {} you are already in JS land so they might not be required when dealing with static and variable values combined like above ..

  • Related