0

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');

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.