I am doing routing on button click event
redirect(){
return ;
}
Its not working.
my home page- base component:
import React, { Fragment } from 'react';
render() {
const { value } = this.state;
return (
From my child component I have to redirect to another component,
here is my child component:
redirect(){
return ;
}
So but I am not getting any console error too.
Answer
is a component. So, you should use it like this.
class App extends React.Component{
state = {
isRedirect: false,
}
redirect = () => {
this.setState({ isRedirect: true });
}
render() {
return (
<>
{this.state.isRedirect ? : null }
>
)
}
}
OR
You can use history API
but you should add withRouter()
class App extends React.Component{
render(){
return(
<>
>
)
}
}
export default withRouter(App);
No comments:
Post a Comment