addMessage = e => {
e.preventDefault();
let data = {
component: this.state.component,
component_name: this.state.component_name
};
this.setState({ current_form: "test-2" });
this.props.addComponent(data);
};
addMessage_test = e => {
e.preventDefault();
let data = {
component: this.state.component,
component_name: this.state.component_name
};
this.setState({ current_form: "test-3" });
this.props.addComponent(data);
};
{current_form == "test-1" && (
<form onSubmit={this.addMessage.bind(this)}>
<input
type="text"
value={this.state.component}
onChange={e => this.setState({ component: e.target.value })}
/>
<input
type="text"
value={this.state.component_name}
onChange={e => this.setState({ component_name: e.target.value })}
/>
<input type="submit" />
</form>
)}
{current_form == "test-2" && (
<form onSubmit={this.addMessage-test.bind(this)}>
<input type="text" placeholder="new" />
<input
type="text"
value={this.state.component}
onChange={e => this.setState({ component: e.target.value })}
/>
<input
type="text"
value={this.state.component_name}
onChange={e => this.setState({ component_name: e.target.value })}
/>
<input type="submit" />
</form>
)}
export const fetchComponents = () => async dispatch => {
let comps = await fire.database().ref("components");
return comps.on("value", snapshot => {
return dispatch({
type: FETCH_ITEMS,
payload: snapshot.val()
});
});
};
content
, она же отвечает за вывод:<ul>{content}</ul>
import * as actions from "../actions";