one
Version:
One is a new React Framework that makes Vite serve both native and web.
25 lines (24 loc) • 649 B
JavaScript
import React from "react";
const Decorated = Symbol();
const withStaticProperties = (component, staticProps) => {
const next = (() => {
if (component[Decorated]) {
const _ = React.forwardRef((props, ref) => React.createElement(component, {
...props,
ref
}));
for (const key in component) {
const v = component[key];
_[key] = v && typeof v === "object" ? {
...v
} : v;
}
}
return component;
})();
Object.assign(next, staticProps);
next[Decorated] = true;
return next;
};
export { withStaticProperties };
//# sourceMappingURL=withStaticProperties.mjs.map