require are translated to imports, with optional destructuring assignment:
import { prune, include as includes } from 'underscore.string';
CSS are imported thanks to webpack:
import '../css/styles.css';
@props are converted to this.props thanks to React.autoBind.
JSX tags stay the same, style properties need commas.
Spread ... operators stay the same.
Multiline strings and template strings need backticks `` instead of single/double quotes. String substitution in template strings need the${var}syntax instead of#{var}`.
var should probably be replaced by either let or const.
ES6 Classes
I personally prefer ES6 Classes over React.createClasses but that would require some more changes in the gatsby codebase and they would be a bit opinionated right now.
Notes about conversion
Automation
I used https://github.com/js2coffee/js2coffee for CoffeeScript files and
https://github.com/jsdf/coffee-react for CJSX ones.
Conversion
require
are translated toimport
s, with optional destructuring assignment:import { prune, include as includes } from 'underscore.string';
CSS are
import
ed thanks to webpack:import '../css/styles.css';
@props
are converted tothis.props
thanks to React.autoBind.JSX tags stay the same,
style
properties need commas.Spread
...
operators stay the same.Multiline strings and template strings need backticks
`` instead of single/double quotes. String substitution in template strings need the
${var}syntax instead of
#{var}`.var
should probably be replaced by eitherlet
orconst
.ES6 Classes
I personally prefer ES6 Classes over
React.createClass
es but that would require some more changes in the gatsby codebase and they would be a bit opinionated right now.