为 clearCookies 导入网络模块

Noi*_*art 5 react-native

我需要clearCookies找到一个隐藏/未记录的功能 - https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/RCTNetworking.android.js

我可以像这样访问它:

import RCTNetworking from 'RCTNetworking'
console.log('RCTNetworking:', RCTNetworking.clearCookies);
Run Code Online (Sandbox Code Playgroud)

它有效,但它正确吗?将import RCTNetworking from 'RCTNetworking'工作存在保证?

我认为这样导入会更安全NativeModules

import { NativeModules } from 'react-native'
console.log('Networking:', NativeModules.Networking.clearCookies);
Run Code Online (Sandbox Code Playgroud)

然而,这会导入NativeModules包含许多其他东西的整体。这不会很糟糕吗?或者在生产中摇树是否删除了我不使用的所有东西NativeModules

还有其他访问方式clearCookies吗?这在任何地方都有记录吗?

jos*_*nez 1

我是RCTNetworking这样导入的:var RCTNetworking = require("RCTNetworking");此导入保证可以在所有平台上运行。
我找不到RCTNetworkingclearCookies()功能的任何文档