While learning react & ES6, I find it surprisingly difficult to evaluate React code (some involving ES6) in an offline REPL type environment (with nodejs).
First of all, ES6 style imports in Node.js REPL is a problem. As the linked question says, I can convert import react
to require('react'), but what about
.css` files? How do I convert something like these?
import './index.css'
Secondly, how do I evaluate JSX? I am evaluating the following from react quick start
const element = (
<h1>
Hello, {formatName(user)}!
</h1>
);
using atom, with the eval-jaavascript
package installed. After hitting cmd-i, I get an error about
SyntaxError: Unexpected token <
...
How can I fix node or atom configurations to be able to evaluate the above lines?
The example runs OK with npm start
, and I know there are on line REPL's. But I just like being able to evaluate code segments in an offline environment in the old fashion line-by-line.
via tinlyx
No comments:
Post a Comment