mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
build(react): build26 from 45504a2b
This commit is contained in:
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
import { useRef } from "react";
|
||||
import { isUndefined } from "@videojs/utils/predicate";
|
||||
//#region src/utils/use-sync-props.ts
|
||||
function useSyncProps(target, props, defaults) {
|
||||
const rest = {};
|
||||
const synced = /* @__PURE__ */ new Set();
|
||||
const prevSyncedRef = useRef(null);
|
||||
const sync = (key, value) => {
|
||||
if (target[key] !== value) target[key] = value;
|
||||
};
|
||||
for (const key of prevSyncedRef.current ?? []) if (isUndefined(props[key])) sync(key, defaults[key]);
|
||||
for (const key in props) if (key in defaults) {
|
||||
if (isUndefined(props[key])) continue;
|
||||
synced.add(key);
|
||||
sync(key, props[key]);
|
||||
} else rest[key] = props[key];
|
||||
prevSyncedRef.current = synced;
|
||||
return rest;
|
||||
}
|
||||
//#endregion
|
||||
export { useSyncProps };
|
||||
|
||||
//# sourceMappingURL=use-sync-props.js.map
|
||||
Reference in New Issue
Block a user