UNPKG

react-native-bluetooth-state-manager

Version:
17 lines (12 loc) 536 B
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;