Tuesday, October 17, 2017

Jest test fails after upgrading to React 16



Made it work by changing the shallow to mount:




Have to learn the difference of mount vs shallow.


Happy Coding!

Monday, October 16, 2017

ts-jest Cannot find name 'test'




There are two ways to fix that. One, import 'jest' directly:




Another way is to put the jest type in tsconfig.json:



Happy Coding!

Thursday, October 12, 2017

React 16 now allows rendering with no root element

This code:
    render() {
        return (
            <div>
                <h1>Hello world!</h1>
                <div>Welcome to hot-reloading React written in TypeScript! {this.state.count}</div>
            </div>
        );
    }


Can now be rendered without the root element (e.g., div) in React 16:
    render() {
        return ([
                <h1>Hello world!</h1>,
                <div>Welcome to hot-reloading React written in TypeScript! {this.state.count}</div>

        ]);
    }


Note the use of array above. This isn't allowed yet though:







Happy Coding!