UNPKG

ra-core

Version:

Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React

19 lines 905 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.genericMemo = void 0; const react_1 = require("react"); /** * A version of React.memo that preserves the original component type allowing it to accept generics. * See {@link https://stackoverflow.com/a/70890101} */ const genericMemo = (component) => { const result = (0, react_1.memo)(component); // We have to set the displayName on both the field implementation and the memoized version. // On the implementation so that the memoized version can pick them up and users may reference the defaultProps in their components. // On the memoized version so that components that inspect their children props may read them. // @ts-ignore result.displayName = component.displayName?.replace('Impl', ''); return result; }; exports.genericMemo = genericMemo; //# sourceMappingURL=genericMemo.js.map