Это должно работать
import React, { useCallback } from 'react';
import { useHistory } from 'react-router-dom';
const ForgotPass = ({ loading, history, reqReset }) => {
const history = useHistory();
const req = useCallback((value) => reqReset(value, history), [history])
return (
<>
...
<Row justify="center">
<Col span={12}>
<Search placeholder="enter your email"
loading={loading}
enterButton={<SyncOutlined />}
onSearch={(value) => req(history)(value)}
type="email"
/>
</Col>
</Row>
</>
)
}
const mapDispatch = dispatch => ({
reqReset: (data) => dispatch(userPassResetReq(data))
})
const mapState = () => createStructuredSelector({
loading: selectLoading
})
export default connect(mapState, mapDispatch)(ForgotPass)
Но это ненормальный способ обработки пу sh. Это решение немного лучше:
import React, { useCallback } from 'react';
import { useHistory } from 'react-router-dom';
const ForgotPass = ({ loading, history, reqReset }) => {
const history = useHistory();
const req = useCallback(async (value) => {
await reqReset(value);
history.push('/to-some-page');
}, [history])
return (
<>
...
<Row justify="center">
<Col span={12}>
<Search placeholder="enter your email"
loading={loading}
enterButton={<SyncOutlined />}
onSearch={(value) => req(history)(value)}
type="email"
/>
</Col>
</Row>
</>
)
}
const mapDispatch = dispatch => ({
reqReset: (data) => dispatch(userPassResetReq(data))
})
const mapState = () => createStructuredSelector({
loading: selectLoading
})
export default connect(mapState, mapDispatch)(ForgotPass)