What is the best why to import this in typescript and get translate into js :
const randomBytes = require('react-native-randombytes').randomBytes;
I do this:
import * as randomBytes from 'react-native-randombyte';
It only give me:
const randomBytes = require('react-native-randombytes');
The syntax you're looking for is:
import { randomBytes } from 'react-native-randombyte';
This essentially means you want to import only randomBytes
, not the entire module. For more information, take a look at the TypeScript documentation here:
https://www.typescriptlang.org/docs/handbook/modules.html#import-a-single-export-from-a-module
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.