React: Building Modern Web Applications
by Jonathan Hayward, Artemij Fedosejev, Narayan Prusty, Adam Horton, Ryan Vice, Ethan Holmes, Tom Bray
The render() method
Next, we implement the render method. What we do is take the properties, which should never be directly mutated and probably should not have any existing value changed, and get the two strings from them. We will, token by token, display everything in the first string, and repeat the second as many times as the component is displayed. We will also create a tokenize function for rendered HTML converted from Showdown—this breaks its argument to each next tag or the next character—and, in a moment, see why we are creating a verbose anonymous function instead of a regular expression (in a nutshell, writing readable code in lieu of a regular expression appears verbose compared to the terseness available in writing write-only code). ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access