patternjavascriptreactCritical
Access props inside quotes in React JSX
Viewed 0 times
jsxpropsaccessquotesinsidereact
Problem
In JSX, how do you reference a value from
For example:
The resulting HTML output is:
props from inside a quoted attribute value?For example:
The resulting HTML output is:
Solution
React (or JSX) doesn't support variable interpolation inside an attribute value, but you can put any JS expression inside curly braces as the entire attribute value, so this works:
Context
Stack Overflow Q#21668025, score: 513
Revisions (0)
No revisions yet.