You may find yourself using inline templates in your directive definitions from time to time.
But it’s kind of painful, right? String concatenation sucks. Putting everything on one line sucks even more.
Do your directive templates look like this?
Here’s a better way
If you’re using ES5, put each line into an array and
Better yet, if you’re already using ES6, use the new natively-supported multiline string. Just surround with backticks:
This has the added benefit of being able to interpolate values inside the strings like this:
Learning React can be a struggle — so many libraries and tools!
My advice? Ignore all of them :)
For a step-by-step approach, check out my Pure React workshop.
Learn to think in React
- 90+ screencast lessons
- Full transcripts and closed captions
- All the code from the lessons
- Developer interviews
Dave Ceddia’s Pure React is a work of enormous clarity and depth. Hats off. I'm a React trainer in London and would thoroughly recommend this to all front end devs wanting to upskill or consolidate.