Skip to content

Instantly share code, notes, and snippets.

@wegry
Created July 18, 2021 13:07
Show Gist options
  • Save wegry/d17568136713cd9bf697aca624acfe3e to your computer and use it in GitHub Desktop.
Save wegry/d17568136713cd9bf697aca624acfe3e to your computer and use it in GitHub Desktop.
<head>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js"
type="application/javascript"
></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js"
type="application/javascript"
></script>
<script>
console.debug('global', React, ReactDOM)
</script>
<script
src="./react-jsonschema-form.js"
type="application/javascript"
></script>
</head>
<body>
<div id="app"></div>
<script>
const Form = JSONSchemaForm.default
const schema = {
title: 'Todo',
type: 'object',
required: ['title'],
properties: {
title: { type: 'string', title: 'Title', default: 'A new task' },
done: { type: 'boolean', title: 'Done?', default: false },
},
}
const log = (type) => console.log.bind(console, type)
ReactDOM.render(
React.createElement(Form, {
schema: schema,
onChange: log('changed'),
onSubmit: log('submitted'),
onError: log('errors'),
}),
document.getElementById('app')
)
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment