Hello i am trying to use react-router with firebase. but it gives me this error.
Cannot read property \'props\' of null
this is exac
In your callback, the this pointer no longer points to your React component. There are many ways to deal with this:
this into another variablevar component = this;
query.on("child_added", function hello (snapshot) {
...
component.props.router.push('Index');
});
thisquery.on("child_added", function hello (snapshot) {
...
this.props.router.push('Index');
}).bind(this);
thisquery.on("child_added", snapshot => {
...
this.props.router.push('Index');
});
Note that this is a very common problem that developers have in JavaScript and I highly recommend you learn more about the way this behaves with callbacks: