Skip to content

Commit

Permalink
autoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
bcherny committed Apr 1, 2018
1 parent 85ee792 commit 2addf3f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react'
import { ComponentType } from 'react'

/**
* TODO: Avoid diffing by passing individual values into a React component
Expand All @@ -23,6 +23,6 @@ export function isImmutable(a: any): a is Immutable {
)
}

export function getDisplayName<T>(Component: React.ComponentType<T>): string {
export function getDisplayName<T>(Component: ComponentType<T>): string {
return Component.displayName || Component.name || 'Component'
}
38 changes: 19 additions & 19 deletions test/immutable.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
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 {
fruits: I.Map<string, number>
}

const initialFruits = {
banana: 100,
};
banana: 100
}

const store = createStore<AppStore>({
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 (
<div>
<button onClick={updateBanana}>Update</button>
<div>{fruits.get('banana')}</div>
</div>
);
});
)
})

withElement(TestingComponent, _ => {
Simulate.click(_.querySelector('button')!)
Simulate.click(_.querySelector('button')!)
Simulate.click(_.querySelector('button')!)
t.is(renderCount, 1);
});
});
t.is(renderCount, 1)
})
})
2 changes: 1 addition & 1 deletion test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import './immutable'
import './stateful'
import './stateless'
import './immutable';
import './utils'

0 comments on commit 2addf3f

Please sign in to comment.