[React] Redirect
1.素子を通して直接に渡された道具が
function Navigation() {
return (
<div className="nav">
<Link to="/">Home</Link>
<Link to={{
pathname:"/about",
state: {
fromNavigation: true
}
}}>About</Link>
</div>
);
}
2.history props経由のRedirectundefined
の場合、直接家に戻るコードclass Detail extends React.Component{
componentDidMount(){
const { location, history } = this.props;
if(location.state === undefined) {
history.push("/");
}
}
render(){
return <span>hello</span>
}
}
Reference
この問題について([React] Redirect), 我々は、より多くの情報をここで見つけました https://velog.io/@nsunny0908/React-Redirectテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol