Skip to content

Commit

Permalink
fix: error when tldraw require localStorage on RN
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Feb 6, 2024
1 parent 04e1943 commit d957c86
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/tw-whiteboard/widget-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
return;
}
// separate the widget from the exports here, so we can skip the require of react code if `!$tw.browser`. Those ts code will error if loaded in the nodejs side.
const components = require('$:/plugins/linonetwo/tw-whiteboard/widget.js');
const { whiteboard } = components;
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
exports.whiteboard = whiteboard;
exports['edit-whiteboard'] = whiteboard;
try {
const components = require('$:/plugins/linonetwo/tw-whiteboard/widget.js');
const { whiteboard } = components;
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
exports.whiteboard = whiteboard;
exports['edit-whiteboard'] = whiteboard;
} catch (error) {
console.error('Error loading tw-whiteboard widget', error);
}
})();

0 comments on commit d957c86

Please sign in to comment.