Novo Componente
import React, {Component} from 'react';
class InputComponent extends Component{
render(){
return(
<div className="pure-control-group">
<label htmlFor={this.props.id}>{this.props.label}</label>
<input id={this.props.id} type={this.props.type} name={this.props.name}
value={this.props.value} onChange={this.props.onChanged}/>
</div>
);
}
}
export default InputComponent;
Classe App
import React, { Component } from 'react';
import './css/pure-min.css';
import './css/side-menu.css';
import $ from 'jquery';
import InputComponent from './components/InputComponent';
...codigo ocultado
render()
{
return (
...codigo ocultado
<form className="pure-form pure-form-aligned" onSubmit={this.enviaForm} method="post">
<InputComponent id="nome" type="text" name="nome" value={this.state.nome} onChange={this.setNome} label="Nome"/>
<div className="pure-control-group">
<label></label>
<button type="submit" className="pure-button pure-button-primary">Gravar</button>
</div>
</form>
...codigo ocultado
);
}
}
export default App;
Erro... Failed to compile ./src/components/InputComponent.js