Reputation: 8499
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');
Upvotes: 0
Views: 71
Reputation: 1238
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
Upvotes: 1