const updateItem = (entity, data, id) => { return dispatch => { return httpService.updateEntity(entity, data, id).then((response) => { history.goBack(); }) .catch((error) => { dispatch(commonAction.failure(error)); }); }; }
//////////////////// // HANDLER METHODS// //////////////////// /** * The handler invoked when the back button is pressed * Uses the History object to navigate to the previous screen */ _handleBackButtonPress() { // preserve context const _this = this; History.goBack(); }
const AuthGuard = ({ component: Component }) => { const [isLoading, setIsLoading] = useState(true); const history = useHistory(); useEffect(() => { amIAdmin().then((result) => (result ? setIsLoading(false) : history.goBack())); }, []); return (isLoading ? <p>loading...</p> : <Component />); }
const GoBack = () => ( <Route> {({ history }) => ( <button onClick={(e) => history.goBack()}>{'<-'}Go Back</button> )} </Route> )
const handleAddProduct = () => { productDispatch({ type: 'add_product', payload: { name, price, description } }) history.goBack() }
const Page2 = () => { const history = useHistory(); const handleClick = () => { history.goBack(); } return ( <div> <Wrapper> <p>This is Page 2</p> </Wrapper> <Button primary onClick={handleClick}>Go Back</Button> </div> ); }
const NavigationBar = () => { const itemCounter = useSelector(state => state.cartIcon) const history = useHistory(); return ( <nav> <ul className={'nav-list'}> <li id={'go-back-button-item'} style={{borderRight: 'solid indigo 2px'}}> <button onClick={() => history.goBack()}> Go Back</button> </li> <Link to={'/'}> <li>Home</li> </Link> <Link to={'/cart'}> <li>Cart ({itemCounter})</li> </Link> {/* disable link to checkout if there are no items in cart*/} <Link to={'/checkout'} style={itemCounter < 1 ? {pointerEvents: 'none'} : null}> <li style={itemCounter < 1 ? {color: 'grey'} : null}>Checkout</li> </Link> </ul> </nav> ); }
const HistoryBackButton = () => { const history = useHistory(); return <BackButton onClick={history.goBack} /> }
function GoBackButton() { const history = useHistory(); return ( <Container> <ButtonArea onClick={() => history.goBack()}> <ArrowWrapper margin="0.6vmin"> <ArrowHead degree={-45} color="black" /> <ArrowHead degree={45} color="black" /> <ArrowBody color="black" /> </ArrowWrapper> <ArrowWrapper margin="0"> <ArrowHead degree={-45} color="white" /> <ArrowHead degree={45} color="white" /> <ArrowBody color="white"> {progresses.map(item => ( <Progress key={item} delay={-ANIMATION_DELAY * item} /> ))} </ArrowBody> </ArrowWrapper> </ButtonArea> </Container> ); }
const Back = () => { let history = useHistory(); return <FaArrowLeft className='back' onClick={() => history.goBack()} />; }
const storeItem = (entity, data) => { return dispatch => { return httpService.storeEntity(entity, data).then((response) => { history.goBack(); }) .catch((error) => { dispatch(commonAction.failure(error)); }); }; }
export default function useNavigator() { const history = useHistory(); function goTo(screen) { const {web: path} = screen; history.push(path); } function goBack() { history.goBack(); } return { goTo, goBack, }; }
/** Navigates backward via the HTML5 History API. */ goBack() { _history.goBack(); return true; }
const back = () => { history.goBack(); }
const goBack = () => { history.goBack(); }