React Native Integration
The b.well composite also supports integration into React Native via a react native scoped export. Before integrating, installation requires adding some peer dependencies of the @icanbwell/composite module.
Installation
Install module plus peer dependencies (only required they are not already installed).
npm install \
react \
react-native \
react-native-webview \
@react-native-async-storage/async-storage
Optional Native Dependencies
The following native dependencies are optional and may be required depending on the features that are enabled for your specific client.
npm install \
react-native-biometrics \
react-native-permissions \
@react-native-camera-roll/camera-roll \
@react-native-camera-roll/camera-roll \
react-native-document-picker \
@react-native-community/geolocation \
react-native-print
Install Pods
npx pod-install
Usage
See Properties table below for all Required and Optional properties.
Make sure to install peer dependencies if they’re not already installed. Our recommended minimum dependences are pinned in the package.json
// Native Module(s) to inject
import storage from '@react-native-async-storage/async-storage';
import { SafeAreaView } from 'react-native';
import { Composite } from '@icanbwell/composite/native';
export default function App() {
return (
<SafeAreaView style={{ flex: 1 }}>
<Composite
clientKey='<CLIENT_KEY>'
userToken='<USER_TOKEN>'
nativeModules={{
storage,
}}
/>
</SafeAreaView>
);
}
The composite should now expose an onEvent prop that will emit an object of the form:
{
"key": "onauthsuccess",
"data": { "user": { "id": "<USER_ID>" } }
}
Example:
<Composite
onEvent={({ key, data }) => {
if (key === 'onauthsuccess') {
console.log('USER ID', data.user.id)
}
}}
clientKey="<CLIENT_KEY>"
userToken="<USER_TOKEN>"
/>
Properties
Property | Required? | Type | Description |
|---|---|---|---|
| Required |
| Client key |
| Required |
| User token for SSO |
| Optional |
| Optional property that tells the composite what page to initially render. Use this to have the Composite render a specific screen. Pass the intended path in via the value property (for example value: '/intended/path'). Use the onResetValue callback to clear the value that is passed to path (set it to an empty string/undefined). onResetValue is called immediately after the passed in path value is rendered within the Composite component. This is required in order to accommodate passing in the same path value sequentially and having the underlying component recognize there’s been a change. It is possible the user navigates elsewhere in between sequential path value updates. NOTE: Make sure to omit the hash segment of a path if it exists. For example: #/intended/path would be /intended/path. |
| Optional |
| Callback property that allows for listening to internal events of the embeddable. |
| Required |
| Property used to inject native dependencies into the composite. At minimum |
Updated 10 days ago
