import React from 'react' import { WalletChatContext } from '../context' import { Text } from 'react-native' const ButtonWrapper = ({ onPress, children, }: { onPress: () => void children: any }) => ( ) const ChatWithOwner = ({ ownerAddress, render, }: { ownerAddress: string render: undefined | React.ReactElement }) => { const wcContext = React.useContext(WalletChatContext) const setWidgetState = wcContext?.setWidgetState const WrapperEl = render ? ({ onPress, children }: { onPress: () => void; children: any }) => React.cloneElement(render, { onPress }, children) : ButtonWrapper if (!wcContext) { console.error( 'WalletChat: ChatWithOwner component must be rendered within a WalletChatProvider' ) return null } return ( setWidgetState && setWidgetState('ownerAddress', { address: ownerAddress, lastRequest: Date.now().toString(), }) } > {!render && ( <>
Chat With Owner )} ) } export default ChatWithOwner