use async function instead of .then
This commit is contained in:
@@ -42,14 +42,14 @@ const createStore = ({
|
|||||||
nodeExtent?: CoordinateExtent;
|
nodeExtent?: CoordinateExtent;
|
||||||
}) =>
|
}) =>
|
||||||
createWithEqualityFn<ReactFlowState>((set, get) => {
|
createWithEqualityFn<ReactFlowState>((set, get) => {
|
||||||
function resolveFitView() {
|
async function resolveFitView() {
|
||||||
const { nodeLookup, panZoom, fitViewOptions, fitViewResolver, width, height, minZoom, maxZoom } = get();
|
const { nodeLookup, panZoom, fitViewOptions, fitViewResolver, width, height, minZoom, maxZoom } = get();
|
||||||
|
|
||||||
if (!panZoom) {
|
if (!panZoom) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fitViewPromise = fitViewport(
|
const viewFitted = await fitViewport(
|
||||||
{
|
{
|
||||||
nodes: nodeLookup,
|
nodes: nodeLookup,
|
||||||
width,
|
width,
|
||||||
@@ -60,10 +60,9 @@ const createStore = ({
|
|||||||
},
|
},
|
||||||
fitViewOptions
|
fitViewOptions
|
||||||
);
|
);
|
||||||
fitViewPromise.then((value) => {
|
|
||||||
fitViewResolver?.resolve(value);
|
fitViewResolver?.resolve(viewFitted);
|
||||||
set({ fitViewResolver: null });
|
set({ fitViewResolver: null });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user