1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | function shouldUpdateReactComponent(prevElement, nextElement) {
|
24 | var prevEmpty = prevElement === null || prevElement === false;
|
25 | var nextEmpty = nextElement === null || nextElement === false;
|
26 | if (prevEmpty || nextEmpty) {
|
27 | return prevEmpty === nextEmpty;
|
28 | }
|
29 |
|
30 | var prevType = typeof prevElement;
|
31 | var nextType = typeof nextElement;
|
32 | if (prevType === 'string' || prevType === 'number') {
|
33 | return nextType === 'string' || nextType === 'number';
|
34 | } else {
|
35 | return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key;
|
36 | }
|
37 | }
|
38 |
|
39 | module.exports = shouldUpdateReactComponent; |
\ | No newline at end of file |