152
rated 0 times
[
157]
[
5]
/ answers: 1 / hits: 16813
/ 6 Years ago, thu, may 24, 2018, 12:00:00
I have component like below it have 4 state values
class ComposedTextField extends React.Component {
state = {
name: '',
title: '',
email: '',
experience: ''
};
handleChange = event => {
this.setState({
[event.target.name]:event.target.value,
[event.target.title]:event.target.value,
[event.target.email]:event.target.value,
[event.target.experience]:event.target.value
});
};
render() {
const { classes } = this.props;
return (
<div>
<Typography variant=headline>Header Info</Typography>
<FormControl fullWidth className={classes.formControl}>
<InputLabel htmlFor=name-simple>Name</InputLabel>
<Input name=name value={this.state.name} id=name-simple onChange={this.handleChange}/>
</FormControl><br></br>
<FormControl fullWidth className={classes.formControl}>
<InputLabel htmlFor=title-simple>Title</InputLabel>
<Input name=title id=title-simple value={this.state.title} onChange={this.handleChange}/>
</FormControl><br></br>
<FormControl fullWidth className={classes.formControl}>
<InputLabel htmlFor=email-simple>Email</InputLabel>
<Input name=email id=email-simple value={this.state.email} onChange={this.handleChange}/>
</FormControl><br></br>
<FormControl fullWidth className={classes.formControl}>
<InputLabel htmlFor=experience-simple>Experience</InputLabel>
<Input name=experience id=experience-simple value={this.state.experience} onChange={this.handleChange}/>
</FormControl><br></br>
</div>
);
}
}
I need to pass those 4 values into another component
function Header(props) {
const { classes, avatar } = props;
return (
<div>
<Typography variant=headline>KASUN FERNANDO</Typography>
<Typography variant=subheading color=textSecondary>
SENIOR DESIGNER-UI/UX
</Typography>
<Typography variant=subheading color=textSecondary>
[email protected]
</Typography>
<Typography variant=subheading color=textSecondary>
4+ years of experience
</Typography>
</div>
);
}
In this component there are 4 typogrphy I need to display that state value in 4 typography
How can I do this please help me im new to React js
More From » reactjs