diff --git a/src/utils.ts b/src/utils.ts index df63cbe..bbfa3cc 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import * as React from 'react' +import { ComponentType } from 'react' /** * TODO: Avoid diffing by passing individual values into a React component @@ -23,6 +23,6 @@ export function isImmutable(a: any): a is Immutable { ) } -export function getDisplayName(Component: React.ComponentType): string { +export function getDisplayName(Component: ComponentType): string { return Component.displayName || Component.name || 'Component' } diff --git a/test/immutable.tsx b/test/immutable.tsx index a1e62c8..f00f54f 100644 --- a/test/immutable.tsx +++ b/test/immutable.tsx @@ -1,8 +1,8 @@ -import * as React from 'react'; -import * as I from 'immutable'; -import { test } from 'ava'; -import { Simulate } from 'react-dom/test-utils'; -import { connect, createStore, Store } from '../src'; +import { test } from 'ava' +import * as I from 'immutable' +import * as React from 'react' +import { Simulate } from 'react-dom/test-utils' +import { connect, createStore, Store } from '../src' import { withElement } from './testUtils' interface AppStore { @@ -10,36 +10,36 @@ interface AppStore { } const initialFruits = { - banana: 100, -}; + banana: 100 +} const store = createStore({ - fruits: I.Map(initialFruits), -}); + fruits: I.Map(initialFruits) +}) -const withStore = connect(store); +const withStore = connect(store) test('[immutable] it should only re-render if something actually changed', t => { - let renderCount = 0; + let renderCount = 0 const TestingComponent = withStore('fruits')(({ store }) => { - const fruits = store.get('fruits'); + const fruits = store.get('fruits') const updateBanana = () => - store.set('fruits')(I.Map(initialFruits)); + store.set('fruits')(I.Map(initialFruits)) - renderCount++; + renderCount++ return (
{fruits.get('banana')}
- ); - }); + ) + }) withElement(TestingComponent, _ => { Simulate.click(_.querySelector('button')!) Simulate.click(_.querySelector('button')!) Simulate.click(_.querySelector('button')!) - t.is(renderCount, 1); - }); -}); + t.is(renderCount, 1) + }) +}) diff --git a/test/test.ts b/test/test.ts index a5420d9..05fe59f 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,4 +1,4 @@ +import './immutable' import './stateful' import './stateless' -import './immutable'; import './utils'