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

Can't add React to App Customizer #7050

Closed
1 of 9 tasks
wonderplayer opened this issue May 28, 2021 · 4 comments
Closed
1 of 9 tasks

Can't add React to App Customizer #7050

wonderplayer opened this issue May 28, 2021 · 4 comments
Labels
Needs: Triage 🔍 Awaiting categorization and initial review. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Comments

@wonderplayer
Copy link

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
  • 💥 Microsoft Edge
  • 💥 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: 90.0.818.66
  • SPFx version: 1.12.1
  • Node.js version: 14.16.1
  • yeoman version: 4.2.0
  • SharePoint generator version: 1.12.1

Describe the bug / error

SPFx is not loaded when I try to use React.
The following message appears in the browser console:

Uncaught (in promise) Error: Failed to create application customizer 'ClientSideExtension.ApplicationCustomizer.970fe979-1d72-4e98-b295-3a9bf1f36291'.
Error information is 'Extension failed to load for componentId "970fe979-1d72-4e98-b295-3a9bf1f36291".'.

Tried on Linux as well with the same versions - doesn't work.

Steps to reproduce

  1. Create a new version of a solution using yeoman generator.
  2. Run npm i react@16 react-dom@16 @types/react@16 @types/react-dom@16 - Office react libraries have dependency on react > 16.8 and < 17, so use version between.
  3. Import react in generated .ts file: import * as React from 'react';
  4. Create basic react element in generated .ts file for app customizer after alert. Use the following line: const a = React.createElement("div", null, null);
  5. Run gulp serve

Expected behavior

Alert gets displayed.

@wonderplayer wonderplayer added the type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. label May 28, 2021
@ghost
Copy link

ghost commented May 28, 2021

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 Awaiting categorization and initial review. label May 28, 2021
@wonderplayer
Copy link
Author

wonderplayer commented May 28, 2021

Resolved.
npm i react@16 was installing 16.14.0 version of react, but actually 16.9.0 is required.
https://docs.microsoft.com/en-us/sharepoint/dev/spfx/compatibility
Spend too much time on this one...

@wonderplayer
Copy link
Author

Also, even if you use npm i [email protected] version 16.14.0 will be installed because npm adds ^ to package version.
I observed that Windows respects ^ sign, but Linux doesn't, so if you want to use React in SPFx, you should explicitly put 16.9.0 in package.

@ghost
Copy link

ghost commented Jun 4, 2021

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

@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Awaiting categorization and initial review. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
Projects
None yet
Development

No branches or pull requests

1 participant