Created
April 18, 2019 11:51
-
-
Save firflant/c93dde731fd983be2eb04aa99cba8119 to your computer and use it in GitHub Desktop.
Basic react-standalone-form usage example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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