react-native-bluetooth-state-manager
Version:
Manage the bluetooth state of your device
17 lines (12 loc) • 536 B
JavaScript
import React from 'react';
import BluetoothStateContext from './BluetoothStateContext';
const isFn = (_) => typeof _ === 'function';
const renderChildren = (children, args) => (isFn(children) ? children(args) : children);
const withBluetoothStateType = (bluetoothState) => ({ children }) => (
<BluetoothStateContext.Consumer>
{(context) => {
return context.bluetoothState === bluetoothState ? renderChildren(children, context) : null;
}}
</BluetoothStateContext.Consumer>
);
export default withBluetoothStateType;