Closed bacancyshreyansh closed 1 year ago
` useEffect(() => { navigation.setOptions({headerLeft: null, headerRight: null});
initialiseP2P().catch(console.error); const onCreateGroup = async () => { await createGroup().then(() => console.log('Group created successfully!'), ); // .catch((err) => console.log("Something went wrong. Details: ", err)); }; const onStartDiscoveringPeers = async () => { await startDiscoveringPeers() .then(() => getAvailablePeers()) .then(({devices}) => console.log('Available Devices: Sync.js ', devices), ); }; const onStopDiscoveringPeers = async () => { await stopDiscoveringPeers().then(() => console.log('Stop discovering was successful'), ); }; const onCancelConnect = async () => { await cancelConnect().then(() => console.log('Connection successfully canceled'), ); }; const onRemoveGroup = async () => { await removeGroup().then( () => console.log("Currently you don't belong to a group!"), setCreateGroupState(true), ); }; if (!props.passSettings) { onCreateGroup().catch(err => console.log('Something went wrong. Details: ', err), ); } else { onStartDiscoveringPeers().catch(err => console.error( `onStartDiscoveringPeers - Something has gone WRONG. Maybe your WiFi is disabled? Error details:`, err ), ); } return () => { if (!props.passSettings) { onRemoveGroup().catch( err => console.error( 'Remove group - Something went wrong. Details: ', err, ), setCreateGroupState(false), ); } else { onStopDiscoveringPeers().catch(err => console.error( `onStopDiscoveringPeers - Something is gone wrong. Maybe your WiFi is disabled? Error details: ${err}`, ), ); if (isDeviceConnected) { onCancelConnect().catch(err => console.error( 'onCancelConnect - Something gone wrong. Details: ', err, ), ); } setIsDeviceConnected(false); } };
}, []);`
Here is my console.log where I get empty device array .
React-Native Version details
I have 2 phones connected through wifi direct but when I try get available devices, it returns an empty array of devices .
@bacancyshreyansh You've attached logs only for 100ms... Can you attach from time when you initialize module till the time when it returns an empty array?
` useEffect(() => { navigation.setOptions({headerLeft: null, headerRight: null});
}, []);`
Here is my console.log where I get empty device array .
React-Native Version details
I have 2 phones connected through wifi direct but when I try get available devices, it returns an empty array of devices .