Published
Edited
Aug 12, 2018
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
render(e(Greatings, { name, color }))
Insert cell
Insert cell
Greatings = ({ name, color }) => e('h1', { style: { color }}, 'Hello ', name, '!')
Insert cell
Insert cell
render(e(StateProvider, { state: { name, color }}, ({ name, color }, setState) => Fragment(
e('h1', {}, 'Advanced component in ', e('span', { style: { color }}, name), '!'),
e('label', {}, 'name: '),
e('input', { type: 'text', value: name, onChange: e => setState({ name: e.target.value})}),
e('br'),
e('label', {}, 'color: '),
e('input', { type: 'text', value: color, onChange: e => setState({ color: e.target.value})}),
e('br'),
e('br'),
)))
Insert cell
Insert cell
Insert cell
renderJSX('global', { GreatingJSX, color, name })`
<global.GreatingJSX color={global.color} name={global.name} />
`
Insert cell
Insert cell
GreatingJSX = jsx`({ color, name }) => (
<h1 style={{ color }}>
Hello {name} with jsx!
</h1>
)`
Insert cell
Insert cell
renderJSX('global', { StateProvider, state: {color, name }})`
<global.StateProvider state={global.state}>
{({color, name }, setState) => (
<React.Fragment>
<h1>Advanced component in <span style={{color}}>{name}</span>!</h1>
<label>name: </label>
<input value={name} onChange={e => setState({ name: e.target.value})} />
<br />
<label>color: </label>
<input value={color} onChange={e => setState({ color: e.target.value})} />
<br />
<br />
</React.Fragment>
)}
</global.StateProvider>
`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
react = require("https://unpkg.com/react@16.2.0/umd/react.production.min.js")
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more