@unsetsoft/ryunixjs 1.2.4-canary.8 → 1.2.4-canary.9

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.
@@ -560,7 +560,6 @@ const commitRoot = () => {
560
560
  commitWork(state.wipRoot.child);
561
561
  state.currentRoot = state.wipRoot;
562
562
  state.wipRoot = null;
563
- state.deletions = []; // Clear deletions after commit
564
563
  };
565
564
 
566
565
  const commitWork = (fiber) => {
@@ -603,13 +602,8 @@ const commitWork = (fiber) => {
603
602
 
604
603
  const commitDeletion = (fiber, domParent) => {
605
604
  if (fiber.dom) {
606
- if (fiber.dom.parentNode === domParent) {
607
- domParent.removeChild(fiber.dom);
608
- } else if (fiber.dom.parentNode) {
609
- // If parent is different, still remove it to be safe and clean the DOM
610
- fiber.dom.parentNode.removeChild(fiber.dom);
611
- }
612
- } else if (fiber.child) {
605
+ domParent.removeChild(fiber.dom);
606
+ } else {
613
607
  let child = fiber.child;
614
608
  while (child) {
615
609
  commitDeletion(child, domParent);
@@ -783,11 +777,11 @@ const useReducer = (reducer, initialState, init) => {
783
777
  hookID: hookIndex,
784
778
  type: RYUNIX_TYPES.RYUNIX_STORE,
785
779
  state: oldHook ? oldHook.state : init ? init(initialState) : initialState,
786
- queue: oldHook ? oldHook.queue : [],
780
+ queue: [],
787
781
  };
788
782
 
789
- if (hook.queue.length > 0) {
790
- hook.queue.forEach((action) => {
783
+ if (oldHook?.queue) {
784
+ oldHook.queue.forEach((action) => {
791
785
  try {
792
786
  hook.state = reducer(hook.state, action);
793
787
  } catch (error) {
@@ -796,35 +790,29 @@ const useReducer = (reducer, initialState, init) => {
796
790
  }
797
791
  }
798
792
  });
799
- hook.queue = [];
800
793
  }
801
794
 
802
- const dispatch =
803
- oldHook?.dispatch ||
804
- ((action) => {
805
- if (action === undefined) {
806
- if (process.env.NODE_ENV !== 'production') {
807
- console.warn('dispatch called with undefined action');
808
- }
809
- return
795
+ const dispatch = (action) => {
796
+ if (action === undefined) {
797
+ if (process.env.NODE_ENV !== 'production') {
798
+ console.warn('dispatch called with undefined action');
810
799
  }
800
+ return
801
+ }
811
802
 
812
- hook.queue.push(action);
813
-
814
- const currentState = getState();
815
- if (currentState.currentRoot) {
816
- currentState.wipRoot = {
817
- dom: currentState.currentRoot.dom,
818
- props: currentState.currentRoot.props,
819
- alternate: currentState.currentRoot,
820
- };
821
- currentState.deletions = [];
822
- currentState.hookIndex = 0;
823
- scheduleWork(currentState.wipRoot);
824
- }
825
- });
803
+ hook.queue.push(action);
804
+
805
+ const currentState = getState();
806
+ currentState.wipRoot = {
807
+ dom: currentState.currentRoot.dom,
808
+ props: currentState.currentRoot.props,
809
+ alternate: currentState.currentRoot,
810
+ };
811
+ currentState.deletions = [];
812
+ currentState.hookIndex = 0;
813
+ scheduleWork(currentState.wipRoot);
814
+ };
826
815
 
827
- hook.dispatch = dispatch;
828
816
  wipFiber.hooks[hookIndex] = hook;
829
817
  state.hookIndex++;
830
818
  return [hook.state, dispatch]