I got a prefer-template error from eslint. For a workaround, I changed my code to use the template string inside the require function, which is nested inside the url function as follows:
{ background: `url(${require(`../../assets/${edge.node.name.toLowerCase()}.png` center no-repeat`)}) }
However, this gave an error, obviously. Here is the code I used before, plus the character concatenating inside the require function instead of the template string.
{ background: `url(${require('../../assets/' + edge.node.name.toLowerCase() + '.png')}) center no-repeat` }
Can I define nested template strings?
javascript ecmascript-6 template-literals
lvarayut
source share