diff --git a/docs/next/platform-specific-code.html b/docs/next/platform-specific-code.html index d743e8b8d81..dc2980e5e9d 100644 --- a/docs/next/platform-specific-code.html +++ b/docs/next/platform-specific-code.html @@ -99,10 +99,19 @@ BigButton.android.js
You can then require the component as follows:
-const BigButton = require('./BigButton');
+import BigButton from './BigButton';
React Native will automatically pick up the right file based on the running platform.
-If you share your React Native code with a website, you might as well use the BigButton.native.js so that both iOS and Android will use this file, while the website will use BigButton.js.
+Native-specific extensions (i.e. sharing code with NodeJS and Web)
+You can also use the .native.js extension when a module needs to be shared between NodeJS/Web and React Native but it has no Android/iOS differences. This is specially useful for projects that has common code shared among React Native and ReactJS.
+For example, say you have the following files in your project:
+Container.js # picked up by Webpack, Rollup or any other Web bundler
+Container.native.js # picked up by the React Native bundler for both Android and iOS (Metro)
+
+You can still require it without the .native extension, as follows:
+import Container from './Container';
+
+Pro tip: Configure your Web bundler to ignore .native.js extensions in order to avoid having unused code in your production bundle, thus reducing the final bundle size.