Skip to content

Instantly share code, notes, and snippets.

@wootsbot
Last active July 13, 2018 03:08
Show Gist options
  • Save wootsbot/46dc18b5aed6e9c90b5b5aa298fd2c5b to your computer and use it in GitHub Desktop.
Save wootsbot/46dc18b5aed6e9c90b5b5aa298fd2c5b to your computer and use it in GitHub Desktop.
import React from 'react'
import {InputText} from 'primereact/inputtext';
import {Button} from 'primereact/button';
class example extends React.Component {
this.state = {}
inputOnChangeTex(event) {
this.setState({[event.target.id]: event.target.value});
}
save = () => {
const {input1, input2} = this.state
const obj = {
input1,
input2,
}
// seria igual a
/*
const obj = {
input1: input1,
input2: input2,
}
*/
}
render() {
const {input1, input2} = this.state
return(
<>
<InputText id="input1" value={input1} onChange={this.inputOnChangeTex} />
<InputText id="input2" value={input2} onChange={this.inputOnChangeTex} />
<Button label="enviar" onClick={this.save}/>
</>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment