Created
March 6, 2020 11:07
-
-
Save arthurescriou/919de34b237e3d8983aad614b5759223 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| type State = { | |
| title?: string, | |
| prix?: number, | |
| euh?: string, | |
| bonjour?: string, | |
| } | |
| class PageArticles extends React.Component { | |
| public state: State | |
| constructor(props: any) { | |
| super(props); | |
| this.state = {}; | |
| this.handleChange = this.handleChange.bind(this); | |
| this.handleSubmit = this.handleSubmit.bind(this); | |
| } | |
| handleChange(field: string) { | |
| return (event: any) => { | |
| const newState: any = { ...this.state } | |
| newState[field] = event.target.value | |
| return this.setState(newState) | |
| }; | |
| } | |
| handleSubmit(event: any) { | |
| console.log(typeof this.state.prix)//c'est une String lol | |
| event.preventDefault(); | |
| } | |
| render() { | |
| return <> | |
| <Card double > | |
| <h1> | |
| Mega card! | |
| </h1> | |
| </Card > | |
| <Cols> | |
| <Card> | |
| <form onSubmit={this.handleSubmit}> | |
| <Input label="Title" placeholder="Title" type="text" | |
| value={this.state.title} | |
| onChange={this.handleChange('title')} | |
| /> | |
| <Input label="Prix" placeholder="Prix" type="number" | |
| value={this.state.prix} | |
| onChange={this.handleChange('prix')} | |
| /> | |
| <Input label="Euh" placeholder="Euh" | |
| value={this.state.euh} | |
| onChange={this.handleChange('euh')} | |
| /> | |
| <Select title="boujour" | |
| value={this.state.bonjour} | |
| onChange={this.handleChange('bonjour')} | |
| > | |
| <option>Choix 1</option> | |
| <option>Choix 2</option> | |
| <option>Choix 4</option> | |
| <option>Choix 5</option> | |
| <option>Choix 3</option> | |
| <option>Choix 7</option> | |
| </Select> | |
| <Button text="Create" /> | |
| <Button text="Cancel" light /> | |
| </form> | |
| </Card> | |
| <Card> | |
| <h1> | |
| Lorem ipsum | |
| </h1> | |
| <TextArea label="truc" /> | |
| </Card> | |
| </Cols> | |
| </> | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment