Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] : 3.0.0-preview.1 : Unable to use mgt-react components in SPFx #2158

Closed
Tracked by #2118
anoopt opened this issue Mar 30, 2023 · 8 comments · Fixed by #2274
Closed
Tracked by #2118

[BUG] : 3.0.0-preview.1 : Unable to use mgt-react components in SPFx #2158

anoopt opened this issue Mar 30, 2023 · 8 comments · Fixed by #2274
Assignees
Labels
bug Something isn't working State: Completed
Milestone

Comments

@anoopt
Copy link
Contributor

anoopt commented Mar 30, 2023

Describe the bug
With v3.0.0-preview.1 of mgt-react, when an mgt-react component is used in an SFPx web part, we get an error saying - Script error for: @microsoft/microsoft-graph-client http://requirejs.org/docs/errors.html#scripterror

To Reproduce
Steps to reproduce the behavior:

  1. Create an SFPx web part (with react as the framework)
  2. Add @microsoft/mgt-spfx and @microsoft/mgt-react packages - version 3.0.0-preview.1
  3. Setup the web part with provider and add an mgt-react component as mentioned here skipping the library part.
  4. Run the code
  5. Add the web part on to a page

Code added in the component

import { Person } from '@microsoft/mgt-react';
// import { Person } from '@microsoft/mgt-react/dist/es6/spfx';
// import { Person } from '@microsoft/mgt-react/dist/es6/generated/react';
...
...
// in render
<Person personQuery="me"></Person>

Expected behavior
The mgt-react component should load in the web part.

Screenshots

On web part load:
image

Logs from console:
image

Another type of error that is seen sometimes on web part load:
image

Environment (please complete the following information):

  • OS: Windows 10
  • Browser: Edge
  • Framework: react
  • Context: SharePoint
  • Version: 3.0.0-preview.1
  • Provider: SharePointProvider

Additional context
Tried the same by deploying @microsoft/mgt-spfx SharePoint Framework package to the tenant and still get the same error.

@anoopt anoopt added bug Something isn't working Needs: Triage 🔍 labels Mar 30, 2023
@ghost
Copy link

ghost commented Mar 30, 2023

Hello anoopt, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

@sebastienlevert
Copy link
Contributor

You would not need mgt-spfx per my understanding. Do you get the same results without the library component package?

@anoopt
Copy link
Contributor Author

anoopt commented Apr 6, 2023

Thanks Seb. Yes. I tried without (and with) the library component. I see the same error.

@sebastienlevert
Copy link
Contributor

There are issues currently with SPFx and MGT in v3. The mgt-spfx-utils has issues with the package and this makes it fail. We are looking into it and will fix for our next preview drop!

@anoopt
Copy link
Contributor Author

anoopt commented Apr 14, 2023

Thank you for the update @sebastienlevert

@gavinbarron gavinbarron self-assigned this May 4, 2023
@gavinbarron
Copy link
Member

I think that the underlying culprit here is that SharePoint is treating the @microsoft/microsoft-graph-client as a library component.
The latest version of the graph client library is 3.0.5 while the SharePoint infrastructure has 3.0.2 as the highest available version.

This is really unfortunate that SharePoint is not able to serve a lower patch version.
Our best bet here is to pin all of our libraries to use 3.0.2 explicitly rather than the ^3.0.0 server range we currently use.

@gavinbarron
Copy link
Member

@anoopt this is fixed in v3.0.0-preview.2 which was released today :)

@anoopt
Copy link
Contributor Author

anoopt commented May 10, 2023

Brilliant all ok now :)

@ghost ghost locked as resolved and limited conversation to collaborators Jun 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working State: Completed
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants