Why would we want to put JavaScript in our JSX?

Question

Why would we want to put JavaScript in our JSX?

Answer

We want to use JavaScript in our JSX to render logic!

When we inject JS into JSX we can make this process of rendering logic (based on things like data, events, and data changing over time) more seamless by putting our markup, the HTML part of JSX, that is based on our logic, the JS part of JSX, together in the same file.

8 Likes