mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-27 19:42:11 +10:00
Add push prop to NamedRedirect to pass on to Redirect
This commit is contained in:
parent
4045146364
commit
78cfe3d75f
1 changed files with 5 additions and 5 deletions
|
|
@ -8,20 +8,20 @@ import { pathByRouteName, withFlattenedRoutes } from '../../util/routes';
|
|||
import * as propTypes from '../../util/propTypes';
|
||||
|
||||
const NamedRedirect = props => {
|
||||
const { name, search, state, params, flattenedRoutes, ...rest } = props;
|
||||
const { name, search, state, params, flattenedRoutes, push } = props;
|
||||
const pathname = pathByRouteName(name, flattenedRoutes, params);
|
||||
const locationDescriptor = { pathname, search, state };
|
||||
return <Redirect to={locationDescriptor} {...rest} />;
|
||||
return <Redirect to={{ pathname, search, state }} push={push} />;
|
||||
};
|
||||
|
||||
const { arrayOf, object, string } = PropTypes;
|
||||
const { arrayOf, object, string, bool } = PropTypes;
|
||||
|
||||
NamedRedirect.defaultProps = { search: '', state: {}, params: {} };
|
||||
NamedRedirect.defaultProps = { search: '', state: {}, push: false, params: {} };
|
||||
|
||||
NamedRedirect.propTypes = {
|
||||
name: string.isRequired,
|
||||
search: string,
|
||||
state: object,
|
||||
push: bool,
|
||||
params: object,
|
||||
flattenedRoutes: arrayOf(propTypes.route).isRequired,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue