React Import Multiple Functions

Viewed 4468
import {test,test1,test3} from 'react'

Is there a way I can do something like this?

import {test,test1,test3} as R from 'react'

So in my code it will be:

R.test();
R.test1();
R.test3();
1 Answers
import * as R from 'somecomponent';

This imports all functions and components which are marked as export in somecomponent and make a group of them as R.

R.test();
R.test1();
R.test2(); 

Or

import { test, test1, test2 } from 'somecomponent';

This imports these functions from somecomponent. They should be exported like this.

export const test = () => {};
export const test1 = () => {};
export const test2 = () => {};

Then you can call them like below:

test();
test1();
test2();
Related