I
I
Igor Shumilovsky2016-05-03 11:18:48
JavaScript
Igor Shumilovsky, 2016-05-03 11:18:48

How to highlight words in ReactJs?

Hello! I have an array of titles and there is a search field, by the text from which words from the array should be searched and highlighted if they start with the entered text.
Those. if we entered javascript isn't awesome , then the string my javascript isn't awesome, sorry will become my javascript isn't awesome , sorry.
How can you do this in React? And in principle, in Javascript?
Forgot to add. The string can contain all sorts of different characters like (, ., ;, ) etc.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Ninja Mate, 2016-05-04
@victorzadorozhnyy

How do you like this idea impromptu)
in the value input field we set from the state, which we collect from
onChange when entering, we run through the array and if there is a match, then set this.props.hlt , if not then this.props.else, when this.props. else matches the value of array, then we reset it and set it in this.props.hlt

R
RubaXa, 2016-05-08
@RubaXa

Use https://facebook.github.io/react/tips/dangerously-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question