There was an error while loading. Please reload this page.
1 parent f5a8b02 commit 58f9a04Copy full SHA for 58f9a04
2 files changed
.changeset/slow-ravens-type.md
@@ -0,0 +1,5 @@
1
+---
2
+"@react-pdf/layout": patch
3
4
+
5
+Prevent Yoga init from running more than once
packages/layout/src/yoga/index.js
@@ -2,14 +2,12 @@
import { loadYoga as yogaLoadYoga } from 'yoga-layout/load';
-let instance;
+let instancePromise;
6
7
export const loadYoga = async () => {
8
- if (!instance) {
9
- // Yoga WASM binaries must be asynchronously compiled and loaded
10
- // to prevent Event emitter memory leak warnings, Yoga must be loaded only once
11
- instance = await yogaLoadYoga();
12
- }
+ // Yoga WASM binaries must be asynchronously compiled and loaded
+ // to prevent Event emitter memory leak warnings, Yoga must be loaded only once
+ const instance = await (instancePromise ??= yogaLoadYoga());
13
14
const config = instance.Config.create();
15
0 commit comments