Skip to content

Instantly share code, notes, and snippets.

@firflant
Created April 18, 2019 11:51
Show Gist options
  • Save firflant/c93dde731fd983be2eb04aa99cba8119 to your computer and use it in GitHub Desktop.
Save firflant/c93dde731fd983be2eb04aa99cba8119 to your computer and use it in GitHub Desktop.
Basic react-standalone-form usage example
import React from 'react'
import ReactDOM from 'react-dom'
import Form, {
FormThemeProvider,
Input,
Select,
FormButton,
} from 'react-standalone-form'
const BasicFormExample = () =>
<Form fields={['name', 'type']}>
<Input
name='name'
label='User name'
/>
<Select
name='type'
label='Type of a user'
options={['Viewer', 'Moderator', 'Admin']}
/>
<FormButton
callback={fields => console.log(fields)}
>Save</FormButton>
</Form>
const App extends React.Component {
render() {
return (
<FormThemeProvider>
<div className='my-app'>
<BasicFormExample />
</div>
</FormThemeProvider>
)
}
}
ReactDOM.render(<App />, document.querySelector('#app'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment