From 271f3f594d6dafcc6f86f8fde3082674fb942c2b Mon Sep 17 00:00:00 2001 From: Website Deployment Script Date: Thu, 15 Jun 2017 16:53:23 +0000 Subject: [PATCH] Updated docs for next --- releases/next/docs/platform-specific-code.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/releases/next/docs/platform-specific-code.html b/releases/next/docs/platform-specific-code.html index 3d793e31d4e..bd0b403acbb 100644 --- a/releases/next/docs/platform-specific-code.html +++ b/releases/next/docs/platform-specific-code.html @@ -25,6 +25,11 @@ if (Platform.Version === 25) { console.log('Running on Nougat!'); +}

Detecting the iOS version #

On iOS, the Version is a result of -[UIDevice systemVersion], which is a string with the current version of the operating system. An example of the system version is "10.3". For example, to detect the major version number on iOS:

import { Platform } from 'react-native'; + +const majorVersionIOS = parseInt(Platform.Version, 10); +if (majorVersionIOS <= 9) { + console.log('Work around a change in behavior'); }

Platform-specific extensions #

When your platform-specific code is more complex, you should consider splitting the code out into separate files. React Native will detect when a file has a .ios. or .android. extension and load the relevant platform file when required from other components.

For example, say you have the following files in your project:

BigButton.ios.js BigButton.android.js

You can then require the component as follows:

const BigButton = require('./BigButton');

React Native will automatically pick up the right file based on the running platform.

← PrevNext →

You can edit the content above on GitHub and send us a pull request!