Jason Chen Jason Chen - 1 month ago 18x
React JSX Question

Can React render ejs?

I have the following ejs tags:

<%=user.profile.name %>

When I compile my React code via Browserify and Reactify (for instance)

browserify -t reactify app/dashboard/dashboard.jsx -o build/dashboard.js

I get an unexpected token error about my
symbols. Are there ways around this? Or am I not supposed to be mixing React with ejs?


No it can't do that. React uses a special syntax called JSX, which you can use to write your view markup. But JSX actually is just syntactic sugar which the transpiler (eg. reactify) transforms into React.createElement() function calls.

Check this section from the docs: https://facebook.github.io/react/docs/jsx-in-depth.html#the-transform