DeloitteAU / react-habitat

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

Typescript usage with Bable compiled Files #9

Closed theladyjaye closed 7 years ago

theladyjaye commented 7 years ago

So Babel does some magic with export default you can see how it conflicts here:

https://github.com/Microsoft/TypeScript/issues/5565#issuecomment-155216760

Supposedly this is being addressed?

https://github.com/babel/babel/issues/2212

Anyway under typescript the example actually becomes:

import * as ReactHabitat from 'react-habitat';
import { Hello } from './components/Hello';

class MyApp extends ReactHabitat.default.Bootstrapper {
    constructor(){
        super();

        // Create a new container builder
        var container = new ReactHabitat.default.Container();

        // Register your top level component(s) (ie mini/child apps)
        container.register('Hello', Hello);

        // Finally, set the container
        this.setContainer(container);
    }
}

// Always export a 'new' instance so it immediately evokes
export default new MyApp();

Note the lookup: ReactHabitat.default.Bootstrapper and ReactHabitat.default.Container()

theladyjaye commented 7 years ago

See: #10

jennasalau commented 7 years ago

Thanks so much for your PR! Legend.

This is now resolved in v4.0.2

We will need to have a look at the ugly default issue in a future release. In the mean time I've added notes to the read me.