Error in Generating HTML Snippet for SPFX Webpart

Highlighted
New Contributor

I have coded a webpart using SPFx framework (React), and am trying to add the webpart into the page layout to avoid any changes by the users. The site is using Classic Experience, and I have coded the Master Page and Page Layout with the help of Design Manager.

 

As per Hardcoding a Webpart in Page Layout, I have exported the webpart, and upload it to the Webpart Gallery. However, when I go to my Page Layout->Snippets, and after selecting my uploaded webpart, it returns the following error.

 

Any idea what is wrong, and is it possible to include a SPFx webpart in the Page Layout/Master Page?

Cannot create an object of type 'System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

 

4 Replies
Highlighted

Hi @Wee Chong Ong

 

Customizing the master page is not a recommended approach and you should try to avoid it.

To prevent undesired users from editing the page where the web part is, you should just ensure that only the desired users have editing access to the site, library, or ultimately, the page.

Highlighted

Hi @Joel Rodrigues

 

 

The page has many components and we will want to only allow the user to edit the wysiwyg editor, and as such we can't just restrict the permission at the page/site level.

 

 

Will you have any idea if SPFx webpart can be added into a page layout/master page with the use of Design Manager?

Highlighted
Not that I'm aware of, but an alternative option could be perhaps to only render the webpart to certain users when the page is on edit mode. You can detect this within the webpart code, and add something to the render method that only display a message telling the user that they can't Edit the web part, or not display anything at all.
This way you would not be breaking best practices for customisations

Hope this help
Highlighted

That won't work too, as users will be able to delete the webpart when they are editing the page.