Reputation: 153
i'm developing a cross platform app and would like to render a checkbox in android and a switch in IOS. For this i'm trying to use the Platform.select functionality from the react native documentation from the following page https://reactnative.dev/docs/platform-specific-code#platform-module.
import {
Modal,
SwitchIOS,
Platform,
} from 'react-native';
import React from 'react';
import CheckBox from '@react-native-community/checkbox';
class MeetingDisplay extends React.Component {
constructor(props) {
super(props);
const PlatformSpecificCheckBox = Platform.select({
ios: () => require('SwitchIOS'),
android: () => require('CheckBox'),
})();
}
....
Everytime i try to run my app on either a device or simulator get "unable to locate SwitchIOS" or "unable to locate Checkbox" if i switch the order of the statements. Any help would be appreciated, thanks.
Edit
Changed the link above.
Upvotes: 0
Views: 227
Reputation: 21
Try this. It worked for me:
const PlatformSpecificCheckBox = Platform.select({
ios: () => SwitchIOS,
android: () => CheckBox,
});
Upvotes: 1