I was needing to clearCookies
and found a hidden/undocumented function - https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/RCTNetworking.android.js
I am able to access it like this:
import RCTNetworking from 'RCTNetworking'
console.log('RCTNetworking:', RCTNetworking.clearCookies);
It works, but is it correct? Will import RCTNetworking from 'RCTNetworking'
work guranteed?
I thought it would be more safe to import from NativeModules
like this:
import { NativeModules } from 'react-native'
console.log('Networking:', NativeModules.Networking.clearCookies);
However this imports the whole NativeModules
which has a bunch of other stuff. Wouldn't this be bad? Or does tree shakingng in production remove all the stuff I don't use from NativeModules
?
Is there another way to access clearCookies
? Is this documented anywhere?
I imported RCTNetworking
like this: var RCTNetworking = require("RCTNetworking");
This import is guaranteed to work on all platforms.
I couldn't find any documentation for RCTNetworking
nor for the clearCookies()
function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With