Package will not load if importing from @microsoft/sp-dialog
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Developer environment
Windows
What browser(s) / client(s) have you tested
- [ ] 💥 Internet Explorer
- [X] 💥 Microsoft Edge
- [X] 💥 Google Chrome
- [ ] 💥 FireFox
- [ ] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [ ] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
- browser version: latest
- SPFx version: 1.16.1
- Node.js version: 16
- typescript version: 4.5.5
- react 17.0.1
- react-dom 17
- removed @microsoft/office-ui-fabric-react-bundle package and used @fluentui/react 8.105.1
Describe the bug / error
When you add the following code anywhere in the SPFx package:
import { BaseDialog, IDialogConfiguration } from '@microsoft/sp-dialog';
and use that code in any way (so tree shaking doesn't remove it), the SPFx package will not be loaded on the browser. Instead you will get the following errors in the console:
- Could not load [library name] in require. Trying in system.js
- Could not load [library name] in require. Trying in system.js
- Uncaught (in promise) Error
- Trace shows its coming from "e.buildLoadComponentError"
and the code in the SPFx package will not execute on the page.
Steps to reproduce
for simplicity, this code doesn't do much except causes the project to blow up.
- Create a ListViewCommandSet component
- Add this code to the import:
import { Dialog } from '@microsoft/sp-dialog';
- add a new class at the end with a test dialog:
export default class TestDialog extends BaseDialog {
public render(): void {
ReactDOM.render(<h1>hello world!</h1>, this.domElement);
}
public getConfig(): IDialogConfiguration {
return { isBlocking: false };
}
protected onAfterClose(): void {
super.onAfterClose();
// Clean up the element for the next dialog
ReactDOM.unmountComponentAtNode(this.domElement);
}
}
- In your command set onInit, add this code:
console.log("my project init");
console.dir(TestDialog);
Expected behavior
two messages would be written to the console.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
The error message in console:

Hi, I'm also running into this issue, but I'm not using the dialog library.

I'm also facing this issue. I tried removing the BaseDialog but it didn't solve it, maybe it has something to do with React or ReactDOM. Another thing I notice is that we are all facing this issue on a command set extension.
Ran into similair issue where Dialog would render once then show blank afterwards.
Tried some different implementations and eventually updated our command set extension to use the FluentUI Dialog component:
import { Dialog, DialogType } from 'office-ui-fabric-react/lib/Dialog';
Based on the implementation here: https://github.com/pnp/sp-dev-fx-extensions/tree/main/samples/react-command-convert-to-pdf/src/extensions/pdfExport
@MattDev93 it's not working for me
Hi, could someone please verify this issue?
@shaipetel were you able to solve this? I should develop an extension but I'm stuck
I will say for me - I re-bundled and packaged my solution and then it decided to work. However I had already tried this numerous times before but it was the first time that day. So, it seems like it self-resolved or there was an issue on the MSFT server side that they fixed.
Also not working for me
it seems you need to explicitly install react and react-dom:
npm i [email protected] [email protected] @types/[email protected] @types/[email protected] --save-exact
@paulcolucci I did install those versions and I think it may have worked. Thank you
We need to change the documentation for the usage of dialogs. You need to explicitly install React as a dependency to create React components.
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues