@harborclient/sdk 1.1.29 → 1.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime/react.js +40 -1
- package/package.json +1 -1
package/dist/runtime/react.js
CHANGED
|
@@ -111,11 +111,48 @@ export function useLayoutEffect(effect, deps) {
|
|
|
111
111
|
return hook('useLayoutEffect')(effect, deps);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/** @type {typeof import('react').useReducer} */
|
|
115
|
+
export function useReducer(reducer, initialArg, init) {
|
|
116
|
+
return hook('useReducer')(reducer, initialArg, init);
|
|
117
|
+
}
|
|
118
|
+
|
|
114
119
|
/** @type {typeof import('react').createElement} */
|
|
115
120
|
export function createElement(type, props, ...children) {
|
|
116
121
|
return hook('createElement')(type, props, ...children);
|
|
117
122
|
}
|
|
118
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Defers host React lookup until render so module-level `React.memo(...)`
|
|
126
|
+
* calls work before activate().
|
|
127
|
+
*
|
|
128
|
+
* @type {typeof import('react').memo}
|
|
129
|
+
*/
|
|
130
|
+
export function memo(Component, propsAreEqual) {
|
|
131
|
+
/** @type {ReturnType<typeof import('react').memo> | null} */
|
|
132
|
+
let Memoized = null;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Lazily wraps the component with host React.memo on first render.
|
|
136
|
+
*
|
|
137
|
+
* @param {Record<string, unknown>} props - Component props.
|
|
138
|
+
* @returns {import('react').ReactElement}
|
|
139
|
+
*/
|
|
140
|
+
function LazyMemo(props) {
|
|
141
|
+
const react = requireHostReact();
|
|
142
|
+
if (Memoized === null) {
|
|
143
|
+
Memoized = react.memo(Component, propsAreEqual);
|
|
144
|
+
}
|
|
145
|
+
return react.createElement(Memoized, props);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const displayName =
|
|
149
|
+
(typeof Component === 'function' ? (Component.displayName ?? Component.name) : null) ??
|
|
150
|
+
'Component';
|
|
151
|
+
LazyMemo.displayName = `Memo(${displayName})`;
|
|
152
|
+
|
|
153
|
+
return LazyMemo;
|
|
154
|
+
}
|
|
155
|
+
|
|
119
156
|
/**
|
|
120
157
|
* Named SDK React exports used as the Proxy target for the default export.
|
|
121
158
|
*/
|
|
@@ -134,7 +171,9 @@ const reactNamespace = {
|
|
|
134
171
|
useContext,
|
|
135
172
|
useId,
|
|
136
173
|
useLayoutEffect,
|
|
137
|
-
|
|
174
|
+
useReducer,
|
|
175
|
+
createElement,
|
|
176
|
+
memo
|
|
138
177
|
};
|
|
139
178
|
|
|
140
179
|
/**
|