-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Description
Why
TLDR: This will create a consistent interface in both react-router-dom and react-router-native, allowing code reuse.
I just started building an app using React Native/React Native Web with the goal of using 99.9% of the same code. I decided to use React Router with it since both the web and native versions offer the same library components (mostly). This allows me to alias react-router-native to react-router-dom with webpack, resulting in the correct library being called based on the platform.
By adding the 'component' prop to the Link component in react-router-dom, cross platform components can be rendered instead of an anchor tag.
Example Usage
<Link
to="/about"
component={TouchableHighlight}
underlayColor='#f0f4f7'
style={styles.navItem}>
<Text>About</Text>
</Link>I already made this change with tests in a forked repo here and the proof of concept project I'm working on is here. If you would like to make this change, I can make a pull request any time.