@unsetsoft/ryunixjs 0.2.26-nightly.9 → 0.2.26
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/lib/dom.js +12 -8
- package/package.json +1 -1
package/lib/dom.js
CHANGED
|
@@ -435,7 +435,7 @@ function createContext(defaultValue) {
|
|
|
435
435
|
let contextValue = defaultValue || null;
|
|
436
436
|
|
|
437
437
|
const context = {
|
|
438
|
-
tag: "
|
|
438
|
+
tag: "RYUNIX_CONTEXT",
|
|
439
439
|
Value: contextValue,
|
|
440
440
|
Provider: null,
|
|
441
441
|
};
|
|
@@ -447,24 +447,28 @@ function createContext(defaultValue) {
|
|
|
447
447
|
|
|
448
448
|
// Hooks
|
|
449
449
|
|
|
450
|
+
/**
|
|
451
|
+
* The function `useContext` is used to read and subscribe to context from your component.
|
|
452
|
+
* @param ref - The `ref` parameter is a reference to a context object.
|
|
453
|
+
* @returns The `Value` property of the `hook` object is being returned.
|
|
454
|
+
*/
|
|
450
455
|
function useContext(ref) {
|
|
456
|
+
hookIndex++;
|
|
457
|
+
|
|
451
458
|
const oldHook =
|
|
452
459
|
wipFiber.alternate &&
|
|
453
460
|
wipFiber.alternate.hooks &&
|
|
454
461
|
wipFiber.alternate.hooks[hookIndex];
|
|
455
462
|
|
|
456
|
-
const
|
|
457
|
-
|
|
463
|
+
const hasOld = oldHook ? oldHook : undefined;
|
|
464
|
+
const Context = hasOld ? hasOld : ref;
|
|
458
465
|
const hook = {
|
|
459
|
-
|
|
460
|
-
...Context.Value,
|
|
461
|
-
__context: Context,
|
|
466
|
+
...Context,
|
|
462
467
|
};
|
|
463
468
|
|
|
464
469
|
wipFiber.hooks.push(hook);
|
|
465
|
-
hookIndex++;
|
|
466
470
|
|
|
467
|
-
return hook;
|
|
471
|
+
return hook.Value;
|
|
468
472
|
}
|
|
469
473
|
|
|
470
474
|
/**
|