In no way can I change the status in one file from another, I tried to send <Smallblock terms='1212' />
, but it doesn't come to console.log(this.props)
Here is the code:
send:
import React, {Component} from 'react'; import Smallblock from './Smallblock'; import '../css/sendpost.css'; class Sendpost extends Component { constructor(props) { super(props); this.state = { text: "" } this.handleTextChange = this.handleTextChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); } handleSubmit(event) { event.preventDefault(); this.setState({text: ""}); <Smallblock terms='1212' /> } handleTextChange(event) { this.setState({text: event.target.value}); } render() { return ( <div className="form_input"> <form onSubmit={this.handleSubmit}> <input type='text' className="inputtext" placeholder="Что у вас нового?" value={this.state.text} onChange={this.handleTextChange} /> <button>Send</button> </form> </div> ); } } export default Sendpost;
Smallblock:
import React, {Component} from 'react'; import '../css/smallblock.css'; class Smallblock extends Component { constructor(props) { super(props); console.log(this.props); alert(this.props); this.state = { count: "1" } } render() { return ( <div className="smallblock"> <div className="count">{this.state.count}</div> <div className="text">Записей</div> </div> ); } } export default Smallblock;