React Base Fiddle (JSX)
Starting point for creating JSFiddles with React.
by twophayse
HTML
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<object data="http://www.example.com" id="container">
<object data="https://www.example.com">
</object>
<!-- This element's contents will be replaced with your component. -->
</object>
<object data="http://www.example.com" id="container">
<object data="https://www.example.com">
</object>
<!-- This element's contents will be replaced with your component. -->
</object>
<span id="container2">
<!-- This element's contents will be replaced with your component. -->
</span>
<span id="container3">
<!-- This element's contents will be replaced with your component. -->
</span>
<span id="container4">
<!-- This element's contents will be replaced with your component. -->
</span>
Babel + JSX
function Hello(props) {
return <h1>Hello, {props.name}</h1>;
}
function Goodbye(props) {
return <h1>Goodbye, {props.name}</h1>;
}
function Child(props) {
let foo = props.children();
return foo;
}
function CommentForm(props) {
let foo = props.children();
return foo;
}
function bar(){
return 3;
}
function baz(){
function bop(){
console.log(Array.from(arguments));
}
return <input defaultValue="4" ref={bop}/>;
}
ReactDOM.render(
<Hello name="World" />,
document.getElementById('container')
);
ReactDOM.render(
<Goodbye name="World" />,
document.getElementById('container2')
);
ReactDOM.render(
<Child>{bar}</Child>,
document.getElementById('container3')
);
// Handle updated values by re-rendering the app
ReactDOM.render(
<CommentForm>{baz}</CommentForm>,
document.getElementById("container4")
);