Reputation: 1057
How do I write a importing is equivalent to import React, { Component } from 'react-native'
?
In typescript(es6 mode), it only accepts, has to split into two importings:
import * as React from 'react-native'
import { Component } from 'react-native'
How do I do?
Upvotes: 0
Views: 1379
Reputation: 275857
In typescript(es6 mode), it only accepts, has to split into two importings:
You have to do it like that. And you should do it like that for Babel as well.
Otherwise you will end up with tears.
This is because React
is not the default export but it is synthetically made one by Babel. It emits a function that copies export =
to default
which is something that TypeScript refuses to do to prevent future troubles.
Upvotes: 5