0

I was following the below tutorial to build custom property pane controls.

https://learn.microsoft.com/en-us/training/modules/sharepoint-spfx-web-part-property-pane/5-exercise-build-custom-controls

But after following the steps, when I try to add the webpart into workbench I am getting the below error in browser console (no error in gulp serve).

Could not load hello-world-web-part in require. Error: Script error for "react"

workbench error screenshot

Tried to search on the issue but unable to find the reason. Could some one please check this and guide me on what mistake am I doing here..

Repo: https://github.com/JefinDX/spfx_learn_01

1 Answer 1

0

The reason for the error was so trivial. I feel pity on myself.

SPFX v1.19.0 supports React v17.0.1 (And I was trying to use v17.0.2 through updating package.json. The project was created using No Framework option and lated I tried to add React into it.)

spfx v1.19 react support

Related: https://github.com/SharePoint/sp-dev-docs/issues/6923#issuecomment-823610274

But why could't spfx webpart just show much more meaning message rather that showing ERROR [object Object]

Found out that the reason for getting [object Object] error was due to an unwanted localizedResources mentioned in config.json. (@pnp/spfx-controls-react was not needed/installed. Don't remember how it got added here in the first place --- ohhh, I have only installed it just to check various things)

"localizedResources": {
    "HelloWorldWebPartStrings": "lib/webparts/helloWorld/loc/{locale}.js",
    "ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js"
  }

Related GitHub issue (super super helpful): https://github.com/SharePoint/sp-dev-docs/issues/9675

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.