Is there a way to highlight a code line inside a react-syntax-highlighter component? You can see the highlight I mean in the image below on line 43.
You can hack on the generated span
s. Firstly, without talking about React, let us use plain jQuery to solve the problem:
Open the demo, then run
$(".language-javascript>span:nth-child(3)").css('background-color', 'blue')
and you will see the 3
rd line being blue!
Secondly, let us make it work in React. You can use some libraries to inject css codes like .language-javascript>span:nth-child(3) {background-color: blue;}
(where 3
is the line number you want to highlight) into React component tree.