score:3

Accepted answer

I've found that a well-designed project can reach a relatively high degree of code-sharing between both iOS and Android - in some instances 85-95% - it depends how complex the app is. The .ios and .android extensions simply exist because it's useful to be able to target each platform specifically - when creating modular components sometimes each OS yields a different challenge, so you have to rethink the architecture. An example is the <Picker> component, which creates a UIPickerView on iOS, but a modal Picker and label on Android - both of which work slightly differently. But in general this isn't the case, at least in my experience.

As the index.js file is the entry-point it therefore serves as the router for many apps, which means you want this to be the same across each platform - so you can actually have just one index.js for all platforms. Sometimes it might be necessary to have platform-specific initialisations and global assignments which would make the separate approach useful.

Web-wise there currently isn't much cross-over (although hopefully this will change). React Native utilises the power of React, while running on top of the native components designed by the iOS and Android teams, and the differences between mobile and web are fairly broad. That having been said there are some components such as React Swipeable Views which work across web and native which is very promising. But for now the two are fairly separate - one sits on the DOM, the other on native SDKs, although both share pretty much everything else, meaning there's good transfer of skills across platforms.


Related Query

More Query from same tag