Reputation: 4050
I'm using reactjs and react router in my web project, and I'm getting an error, here is the code.
App.js
import React from 'react';
import {Router, Route, Link, browserHistory} from 'react-router'
import NewuserInfo from './NewUserInfomationComponent'
class AppComponent extends React.Component {
render() {
return (
<Router history={browserHistory}>
<Route path="/new/user/:pid" component={NewuserInfo}></Route>
</Router>
);
}
}
NewUserInfomationComponent.js
class NewUserInfomationComponent extends React.Component {
constructor(){
super(props)
this.state = {
ddiabetes: moment(),
pid: this.props.params.pid,
pmh : {},
pmh_con: '',
pmh_date: '',
pmh_mng: ''
}
}
In the following code when running I'm getting an error,
Uncaught ReferenceError: props is not defined
How can I fix this? Thanks
Upvotes: 3
Views: 2273
Reputation: 3656
You are not passing props to the constructor
. constructor
takes props
as first argument and context
as the second.
Upvotes: 3