Reputation: 659
how to use import statement to import functions from one component to other component.
Below is how the import statement is:
import Tool from '../Common';
import { ToolContextProvider } from '../Common';
This complaint of duplicate lines. So I have tried something like below,
import { ToolContextProvider, Tool} from '../Common';
But this doesn't seem to be correct. How can write this in one line. Could someone help me with this? Thanks.
Upvotes: 1
Views: 788
Reputation: 7460
basically there are two different type of export in javascript modules (also react included):
default export would be like :
// someFile.js
export default SomeComponent
named export would be like
// someFile.js
export SomeOtherComponent
importing them in other components for using them should be like:
// useCase.js
import SomeComponent from './someFile' // for default export
import { SomeOtherComponent } from './someFile' // for named export
import SomeComponent, { SomeOtherComponent } from './someFile' // for using both
Upvotes: 4
Reputation: 7166
You can import
like this. Just combine both of them.
import Tool, { ToolContextProvider } from '../Common';
Upvotes: 4