개인 프로젝트 코드
react-router-dom 의 Link를 활용해서 props를 보내기
간단한 검증을 위해서 필요하다
/* /signup */
import { Link, withRouter } from 'react-router-dom';
const Singup = () => {
/* 생략 */
<>
/* 생략 */
<Link
className='btn'
isChecked={isChecked}
disabled={!isChecked}
to={{
pathname: `${match.path}/method`,
state: {
isValid: true,
},
}}
>
Setup my account
</Link>
</>
}
```javascript
/* /signup/method */
import React from 'react';
import { Link, withRouter, Redirect } from 'react-router-dom';
import { SignupWraaper } from '../styles';
const Method = ({ location }) => {
const { state } = location;
return (
<>
{state?.isValid ? (
<SignupWraaper>
/*생략*/
</SignupWraaper>
) : (
<Redirect to='/signup' />
)}
</>
);
};
export default withRouter(Method);