When does React Native select platform-specific code, compiling or running?

Viewed 351

Case 1:

const MyComponent = () => Platform.select({
  ios: <MyComponentIos>,
  android: <MyComponentAndroid>,
});

In this case, I guess that React Native gets platform info and selects components dynamically in running. But how about the next case:

Case 2:

MyComponent.android.jsx:

// ...
export default MyComponentAndroid;

MyComponent.ios.jsx:

// ...
export default MyComponentIos;

App.jsx:

import MyComponent from './MyComponent';

Does React Native choose the correct module in running?

Or in compiling(at least like it should not bundle the .android.jsx file into an ios build)?

And why?

0 Answers
Related