0

ReactJS: "Uncaught SyntaxError: Unexpected token <"

This question is related to the above link,

If I want to do the below

React.render(
        <Lander />,
        document.getElementById('content')
    );

in Ajax success, which is in js file. how to do that?

Means, render will be in separate normal js file and the react component will be in jsx

Community
  • 1
  • 1
Viuu -a
  • 108
  • 1
  • 12
  • why don't you move all of your js files into a jsx file and make ajax call inside jsx file? –  Oct 20 '15 at 06:12
  • You can do jquery code on the backend as well using the npm module - https://www.npmjs.com/package/jquery. and compile into client code using build tools like webpack –  Oct 20 '15 at 06:32
  • I don't think you can do that because `` is obviously a JSX syntax and you need to compile it. It indeed doesn't matter whether your file is JS or JSX as long as you specify your 'JSX compiler' to compile that file. – Natural Lam Oct 20 '15 at 07:17
  • Only for React component I need JSX. Not for other jquery functionalities. U can refer this link for more info http://stackoverflow.com/questions/33232376/backbone-and-react-with-ajax. I tried adding the JSX transformer in my html – Viuu -a Oct 20 '15 at 09:05
  • You are not transpiling the file through a JSX transpiler (use babel). Don't use a on-the-fly transformer for anything other than local messing around (too slow). – Dominic Oct 20 '15 at 09:46
  • So my production code will only have JS not JSX right? I need to use babel to convert those JSX file to JS and have to use it for production. – Viuu -a Oct 20 '15 at 09:51

0 Answers0