reactjs / express-react-views

This is an Express view engine which renders React components on server. It renders static markup and *does not* support mounting those views on the client.
Other
2.73k stars 261 forks source link

SyntaxError: Unexpected token < #129

Closed max8hine closed 6 years ago

max8hine commented 6 years ago

My code run into SyntaxErro: Unexpected Toeken < when there is a parent component.

I just did really simple example Default.jsx which wraps Index.jsx and couldn't fund out which part goes wrong.

-- Env -- react@16.0.0 (under Project's peerDependency) react-dom@16.0.0 (under Project's peerDependency) (React@16.2.0 got same issue)

If parent Component only returns Javascript, not HTML, works fine. If without require parent component, works fine.

Github: https://github.com/max8hine/expressApp/tree/master/templates

zpao commented 6 years ago

The babel transform we do at runtime only happens for the views directory (https://github.com/max8hine/expressApp/blob/master/app.js#L18). Anything outside of that will need to be pre-transformed (eg npm dependencies). If you want our transform running on other code it will need to be in the views dir.

max8hine commented 6 years ago

Hooray, it works. It was my fault b/c the documents explained it clearly.