从A页面跳转到B页面,从B页面返回A页面保留A页面的填写的内容
import { useState, useEffect } from 'react';
const A = (props) => {
const { history } = props
const [form, setForm] = useState<any>({})
const toB = () => {
history.push('/b', { ...from })
}
//state
useEffect(() => {
if(props.location.state) {
setForm({ ...props.location.state })
}
}, [props?.location?.state])
}
export default A
const B = (props) => {
const { location } = props
const toA = () => {
const newState = { ...location.state, 添加你需要传给a页面的参数 };
props.history.replace('/masterCard',{...newState})
}
}
export default B