Skip to content

Instantly share code, notes, and snippets.

@FiberJW
Created November 10, 2019 07:25
Show Gist options
  • Save FiberJW/271fc276e97f98166acea1ed4a8511d2 to your computer and use it in GitHub Desktop.
Save FiberJW/271fc276e97f98166acea1ed4a8511d2 to your computer and use it in GitHub Desktop.
Universal React Router API for Expo Web
import { Platform } from 'react-native';
// hack to get webpack to not bundle native lib
const rrn = 'react-router-native';
export {
Route,
Switch,
Redirect,
useHistory,
useLocation,
useParams,
useRouteMatch,
generatePath,
} from 'react-router';
export const Router =
Platform.OS === 'web' ? require('react-router-dom').BrowserRouter : require(rrn).NativeRouter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment