UNPKG

654 BJavaScriptView Raw
1import * as React from 'react';
2/**
3 * Component which prevents updates for children if no props changed
4 */
5
6function StaticContainer(props) {
7 return props.children;
8}
9
10export default /*#__PURE__*/React.memo(StaticContainer, (prevProps, nextProps) => {
11 const prevPropKeys = Object.keys(prevProps);
12 const nextPropKeys = Object.keys(nextProps);
13
14 if (prevPropKeys.length !== nextPropKeys.length) {
15 return false;
16 }
17
18 for (const key of prevPropKeys) {
19 if (key === 'children') {
20 continue;
21 }
22
23 if (prevProps[key] !== nextProps[key]) {
24 return false;
25 }
26 }
27
28 return true;
29});
30//# sourceMappingURL=StaticContainer.js.map
\No newline at end of file