import {Motion, spring} from 'react-motion'; // In your render... <Motion defaultStyle={{x: 0}} style={{x: spring(10)}}> {value => <div>{value.x}</div>} </Motion>
can be written equivalently as
var ReactMotion = require("react-motion"); var Motion = ReactMotion.Motion; var spring = ReactMotion.spring;
without ES6 features, but using JSX.
Only two things that are very different (with links to related documents):
Also, syntax like <Motion defaultStyle={{x: 0}} style={{x: spring(10)}}> often confused, but remember that attr={} allows you to pass a JS expression, and the expression is just an object literal. This is functionally equivalent to:
var defaultStyle = {x: 0}; var style = {x: spring(10)}; <Motion defaultStyle={defaultStyle} style={style}>
source share