DeloitteAU / react-habitat

⚛️ 🛅 A React DOM Bootstrapper designed to harmonise a hybrid 'CMS + React' application.
Other
262 stars 42 forks source link

fix import ReactHabitat syntax in README.md #25

Closed samuelalvin closed 6 years ago

samuelalvin commented 6 years ago

In Typescript, importing ReactHabitat this way: import ReactHabitat from 'react-habitat';, cause this error:

(TS) Module '"react-habitat"' has no default export

Importing it this way: import * as ReactHabitat from 'react-habitat'; solves the problem.

jennasalau commented 6 years ago

Hey Samuel,

Thanks for the PR. I am a little reluctant to update the docs to use an import *. Reasons being, while this also works in ES6 its not really a javascript standard when we have a default export. Not even React themselves do it in their docs

However, as you mention Typescript users need to use the import * syntax. We've just assumed TS users would know this but perhaps we should make a specific note of this in the docs. If you updated this PR that just adds a small note under the first example for our typescript users I would be happy to merge it.

samuelalvin commented 6 years ago

Hi @jennasalau,

I've reverted the code and add the import note for Typescript user below the example as you suggest. Let me know if there is more that I need to tweak.