Skip to content

Commit

Permalink
refactor: defer loading of DragDropContext until mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Nov 23, 2024
1 parent fcdf346 commit c3557ab
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/core/components/DragDropContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type DeepestParams = {

const AREA_CHANGE_DEBOUNCE_MS = 150;

export const DragDropContext = ({ children }: { children: ReactNode }) => {
const DragDropContextClient = ({ children }: { children: ReactNode }) => {
const { state, config, dispatch, resolveData } = useAppContext();

const [preview, setPreview] = useState<Preview>(null);
Expand Down Expand Up @@ -401,3 +401,13 @@ export const DragDropContext = ({ children }: { children: ReactNode }) => {
</dragListenerContext.Provider>
);
};

export const DragDropContext = ({ children }: { children: ReactNode }) => {
const { status } = useAppContext();

if (status === "LOADING") {
return children;
}

return <DragDropContextClient>{children}</DragDropContextClient>;
};

0 comments on commit c3557ab

Please sign in to comment.