I'm working on a chrome extension, specifically the content script functionality which injects my js into a website.
Since I'm basically just working with a .js fil that gets injected, I am unable to make make this declaration which seems necessary for jsx to work.
<script type="text/jsx">
/**@jsx React.DOM*/
Is there any other way I can utilize JSX?
JSX is not a requirement for using React. Using React without JSX is especially convenient when you don't want to set up compilation in your build environment. Each JSX element is just syntactic sugar for calling React.
Coding JSXJSX allows us to write HTML elements in JavaScript and place them in the DOM without any createElement() and/or appendChild() methods. JSX converts HTML tags into react elements. You are not required to use JSX, but JSX makes it easier to write React applications.
The ${} is template literals.
Since running the JSX transformation is slower than not running it, you probably want to just precompile the JSX (using the jsx
binary provided by react-tools
) when you distribute the extension. That said, if you include JSXTransformer.js then there's a JSXTransformer.exec(...)
method which transforms and evals its argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With