为什么我的道具没有被React路由器中的组件接收

时间:2019-07-09 19:41:23

标签: reactjs react-router

Header.js

import React, {Component} from "react";
import { BrowserRouter as Router, Route, Link, Switch, withRouter, browserHistory, IndexRoute } from "react-router-dom";
...
<Router>
  <Switch>
    <Route path="/PSli" render={(props) => <PSli text="Hello, " {...props} />} />
  </Switch>
</Router>

PSli.js

import React, {Component} from "react"

class PSli extends Component {
  constructor(props) {
    super(props)
    this.state = {
      loading: true,
      timer: true,
      numOfSlides: 4,
      whichSlideActive: 0,
      slideData: {}
    }
  }
  componentDidMount() {
    console.log("mounted" + this.props.text)
    this.setState({
      loading: false
    })
  }

  render() {
    return (
      <div>
      </div>
    )
  }
}

export default PSli

道具怎么没从Header发送到PSli

0 个答案:

没有答案