Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kale-stew committed May 26, 2020
1 parent 412ef05 commit 3ebe93d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
24 changes: 5 additions & 19 deletions test/typescript/sample-react-redux-usage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
// useSelector
import { Provider } from 'react-redux';
import { Provider, useSelector, DefaultRootState } from 'react-redux';
import { createStore } from 'redux';

import equal from '../../index.js';
Expand All @@ -23,23 +23,10 @@ const testArr: IItem[] = [
{ text: 'air', id: '8' },
];

type IChildProps = {
item: IItem;
};

class TestChild extends React.Component<IChildProps> {
shouldComponentUpdate(nextProps: IChildProps) {
return !equal(this.props, nextProps);
}

render() {
const { text: word } = this.props.item;
return <div>{word}</div>;
}
interface IContainerState extends DefaultRootState {
overlap: IItem[];
}

type IContainerState = { overlap: IItem[] };

const overlap = (state = [], action) => {
switch (action.type) {
case 'ADD_ITEM':
Expand All @@ -53,15 +40,14 @@ const store = createStore(overlap, ['mountain']);

class TestContainer extends React.Component<{}, IContainerState> {
render() {
// to interact with the store
// store.dispatch({ type: 'TYPE', text: 'some-text' })
useSelector(this.state, equal);

return (
<div>
Testing react-redux
<div>
{testArr.map((item) => (
<TestChild key={item.id} item={item} />
<p key={item.id}>{item.text}</p>
))}
</div>
</div>
Expand Down
8 changes: 3 additions & 5 deletions test/typescript/sample-usage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ const testArr: ITodo[] = [
{ text: 'mountain', id: '11' },
{ text: 'air', id: '8' },
{ text: 'plants', id: '9' },
{ text: 'air', id: '8' },
{ text: 'air', id: '8' },
];

type IChildProps = {
type IProps = {
todo: ITodo;
};

class TestChild extends React.Component<IChildProps> {
shouldComponentUpdate(nextProps: IChildProps) {
class TestChild extends React.Component<IProps> {
shouldComponentUpdate(nextProps: IProps) {
return !equal(this.props, nextProps);
}

Expand Down

0 comments on commit 3ebe93d

Please sign in to comment.