UNPKG

@talend/react-containers

Version:

Provide connected components aka containers for @talend/react-cmf based on @talend/react-components.

42 lines (41 loc) 1.01 kB
import PropTypes from 'prop-types'; import { useLayoutEffect } from 'react'; import { cmfConnect } from '@talend/react-cmf'; import { AppLoader } from "@talend/react-components"; import { jsx as _jsx } from "react/jsx-runtime"; export const REDIRECT_ACTION_TYPE = 'REDIRECT'; /** * @param {object} props react props * @example <Redirect name="Hello world"></Redirect> */ function Redirect({ path, to, dispatch, componentId }) { useLayoutEffect(() => { dispatch({ type: REDIRECT_ACTION_TYPE, componentId, cmf: { routerReplace: to || path } }); }, [dispatch, path, to, componentId]); return /*#__PURE__*/_jsx(AppLoader, {}); } Redirect.propTypes = { path: PropTypes.string, to: PropTypes.string, dispatch: PropTypes.func, componentId: PropTypes.string }; Redirect.displayName = 'Redirect'; export default cmfConnect({ omitCMFProps: true, withDispatch: true, withComponentId: true })(Redirect); //# sourceMappingURL=Redirect.container.js.map