0
Это мой app.jsреагировать компоненту Issue маршрут
import React from 'react'
import { render } from 'react-dom'
import { Router, Route, IndexRoute, browserHistory } from 'react-router'
const App = ({ children }) => (
<div>
{children}
</div>
)
import Index from './index'
import Eng from './wEng'
import Ar from './wAr'
render((
<Router history={browserHistory}>
<Route path="/simply" component={App}>
<IndexRoute component={Index}/>
<Route path="/A" component={Ar}/>
<Route path="/e" component={Eng}/>
</Route>
</Router>
), document.getElementById('app'))
И это мой index.js
import React from 'react';
import ReactDOM from 'react-dom';
import $ from "min-jquery";
import axios from "axios";
import { render } from 'react-dom'
import WEng from './wEng'
import WAr from './wAr'
import {Link} from 'react-router';
const urlP=`http://localhost:3000/blah`;
export default class App extends React.Component {
constructor(props){
super(props);
this.state={
imagedayA:[],
imagenightA:[]
};
}
componentDidMount() {
axios.get(urlP)
.then(function (response) {
console.log(response.data,"this is response")
this.setState({
imagedayA:response.data.today.iconday,
imagenightA:response.data.today.iconnight
})
}.bind(this))
.catch(function (response) {
console.log(response);
});
}
render(){
if(this.state.component) {
return this.state.component;
}
return (
<div>
<span><button className=" button1" onClick={() => this.setState({component: <WAr {...this.state} />})}>Ar</button></span>
<span><button className=" button2" onClick={() => this.setState({component: <WEng {...this.state} />})}>Eng</button></span>
</div>
);
};
}
Это ВОЙНА компонент:
import React from 'react'
import WEng from './wEng'
import Index from './index'
export default class App extends React.Component {
render() {
return <div>
<div className="mainAr">
<img className="today_imgAr" src={this.props.imagedayA}/>
<p className="tempdayAar">{this.props.tempdayA}<span className="degree">°</span></p>
</div>
</div>
}
}
Я хочу, чтобы добавить кнопка к компоненту wAr, поэтому, когда я нажимаю на нее, я беру меня из компонента wAr, который я вхожу в компонент WEng, как это сделать, используя реакцию.