// @flow import React from "react"; import { View, Text, AsyncStorage } from "react-native"; // import atcCookieImage from '../imgs/atc-cookie-logo.png'; import { Link } from "react-router-native"; import RouterButton from "react-router-native-button"; import { compose, withHandlers, withState } from "recompose"; import { withRouterContext } from "../enhancers/routeEnhancers"; import theme from "../ui-theme"; type Props = { skipIfAlreadyChosen: () => void, setLoading: (val: boolean) => void, loading: boolean, router: { history: { replace: (route: string) => void } } }; const LandingPage = ({ skipIfAlreadyChosen, loading }: Props) => { if (loading) { skipIfAlreadyChosen(); return null; } return ( {/* */} We need to use your location to bring you the best experience possible. I'd rather not. ); }; export default compose( withRouterContext, withState("loading", "setLoading", true), withHandlers({ skipIfAlreadyChosen: (props: Props) => async () => { const zipcode = await AsyncStorage.getItem("zipcode"); if (zipcode) { props.router.history.replace("/list/food"); } else { props.setLoading(false); } } }) )(LandingPage);