Published
Edited
Jan 12, 2021
Importers
2 stars
Insert cell
Insert cell
{
let parent = html`<div>`;
render(m('div', 'Hello, ', 'world!'), parent);
return parent;
}
Insert cell
Insert cell
render = ReactDOM.render
Insert cell
m = function(type, attrs, ...children) {
return isAttributeObject(attrs)
? React.createElement(...arguments)
: // is `children` or `...children` more efficient?
React.createElement(type, null, attrs, ...children);
}
Insert cell
cls = require('classnames@2.2')
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function Example() {
// Declare a new state variable, which we'll call "count"
const [count, setCount] = useState(0);

return m(
'div',
m('p', `You clicked ${count} times`),
m('button', { onClick: () => setCount(count + 1) }, 'Click me')
);
}
Insert cell
{
let parent = html`<div>`;
render(m(Example), parent);
return parent;
}
Insert cell
Insert cell
el = m('div')
Insert cell
React = r('react')
Insert cell
ReactDOM = r('react-dom')
Insert cell
Insert cell
// This 'r' method is like 'require', but it will
// know how to require the correct file from React’s publish module.
r = require.alias({
react: "react@16/umd/react.production.min.js",
"react-dom": "react-dom@16/umd/react-dom.production.min.js"
})
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