Вы немного усложняете это. Я бы упростил его примерно так:
Приложение. js
import React, { Component } from 'react';
import './styles.css';
import Header from './Header';
class App extends Component {
handleNote = ({ note, noteColor }) => {
console.log('note', note);
console.log('notecolor', noteColor);
this.setState({
noteTitle: note,
noteColor,
});
};
render() {
console.log('this.state', this.state);
return (
<div>
<Header handleNote={this.handleNote} />
</div>
);
}
}
export default App;
Заголовок. js
import React, { Component } from 'react';
import './styles.css';
class Header extends Component {
constructor(props) {
super(props);
const initialState = {
note: '',
noteColor: 'white',
}
this.state = initialState;
this.handleChange.bind(this);
}
handleChange = ({ target: { name, value } }) => {
this.setState({
[name]: value,
});
};
render() {
return (
<form
onSubmit={e => {
e.preventDefault();
this.props.handleNote(this.state);
// reset local state
this.setState(initialState);
}}
>
<label htmlFor="name" className="sr-only">
Type anything that you need to know for later...
</label>
<input
type="text"
name="note"
placeholder={this.state.placeholder}
onChange={this.handleChange}
value={this.state.note}
required
/>
<div className="radio-container">
<label htmlFor="yellow" className="sr-only">
White
</label>
<input
onChange={this.handleChange}
type="radio"
name="noteColor"
value="white"
id="white"
/>
<label htmlFor="yellow" className="sr-only">
Yellow
</label>
<input
onChange={this.handleColor}
type="radio"
name="color"
value="yellow"
id="yellow"
/>
<label htmlFor="yellow" className="sr-only">
Red
</label>
<input
onChange={this.handleColor}
type="radio"
name="color"
value="red"
id="red"
/>
<label htmlFor="yellow" className="sr-only">
Green
</label>
<input
onChange={this.handleColor}
type="radio"
name="color"
value="green"
id="green"
/>
<label htmlFor="yellow" className="sr-only">
Blue
</label>
<input
onChange={this.handleColor}
type="radio"
name="color"
value="blue"
id="blue"
/>
<label htmlFor="yellow" className="sr-only">
Purple
</label>
<input
onChange={this.handleColor}
type="radio"
name="color"
value="purple"
id="purple"
/>
</div>
</form>
);
}
}
export default Header;