I'm writing some documentation in React and getting a syntax error when I try to write JavaScript within the render function. I'm not sure if this is a security issue with a workaround or if it's actually a parser issue:
export default class Docs extends Component {
render = () =>
<div>
<h1>Example:</h1>
<div className={styles['code-block']}>
`
import Calendar from './Calendar'
const config = {
api_key: 1234,
calendars: [{ name: 'demo', url: '[email protected]' }]
}
`
</div>
</div>
}
I've tried both with the back tick and without but still get the same syntax error:
Module build failed: Syntax Error: Unexpected token, expected }
referencing the colon just after api_key. Is there a way to do this, or am I better off taking a different approach.
{``}, right now the parser is confused at what should be escaped to actual JS and what is a string in JSX${}wrapped stuff in there. or escape it within the string.