Skip to content

Commit

Permalink
Memoize getGeneratedStyleMapping instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Federkun committed Jun 30, 2020
1 parent ea4a362 commit c9779d0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
"dependencies": {
"@eva-design/dss": "^2.0.0",
"@eva-design/processor": "^2.0.0",
"fecha": "3.0.3",
"hoist-non-react-statics": "^3.2.1",
"lodash.merge": "^4.6.1",
"fecha": "3.0.3"
"memoize-one": "^5.1.1",
"react-fast-compare": "^3.2.0"
},
"peerDependencies": {
"react-native-svg": "^9.13.6"
Expand Down
4 changes: 4 additions & 0 deletions src/components/theme/style/styleConsumer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
ControlThemedStyleType,
ThemedStyleType,
} from '@eva-design/dss';
import isEqual from 'react-fast-compare';
import memoizeOne from 'memoize-one';
import { StyledComponentProps } from './styled';
import {
Interaction,
Expand Down Expand Up @@ -49,6 +51,8 @@ export class StyleConsumerService {

console.error(message);
}

this.getGeneratedStyleMapping = memoizeOne(this.getGeneratedStyleMapping.bind(this), isEqual)
}

public createDefaultProps<P extends object>(): StyledComponentProps {
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10105,6 +10105,11 @@ mem@^4.0.0:
mimic-fn "^2.0.0"
p-is-promise "^2.0.0"

memoize-one@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/memoize-one/-/memoize-one-5.1.1.tgz#047b6e3199b508eaec03504de71229b8eb1d75c0"
integrity sha512-HKeeBpWvqiVJD57ZUAsJNm71eHTykffzcLZVYWiVfQeI1rJtuEaS7hQiEpWfVVk18donPwJEcFKIkCmPJNOhHA==

memory-fs@^0.4.0, memory-fs@^0.4.1, memory-fs@~0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552"
Expand Down Expand Up @@ -12741,6 +12746,11 @@ react-error-overlay@^6.0.1:
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.7.tgz#1dcfb459ab671d53f660a991513cb2f0a0553108"
integrity sha512-TAv1KJFh3RhqxNvhzxj6LeT5NWklP6rDr2a0jaTfsZ5wSZWHOGeqQyejUp3xxLfPt2UpyJEcVQB/zyPcmonNFA==

react-fast-compare@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb"
integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==

react-is@^16.12.0, react-is@^16.13.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.9.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
Expand Down

0 comments on commit c9779d0

Please sign in to comment.