React
11 TopicsSPFX 18.2 gulp serve issues
I have recently updated a number of modern spfx webparts to spfx 18.2 and this morning when I try to debug in workbench (locally and on tenant) I am getting serve errors in relation to react and react-dom I am able to serve projects not using react successfully but when using spfx 18.2 but not react 16.8.4 - has anybody else encountered this issue. I have restored to previous code backup, as well as restoring to previous days last git commit neither had a positive effect. I get no errors in terminal but workbench shows the following message: SPLoaderError.loadComponentError]: ***Failed to load component "174429f3-8ff8-4143-8f12-7c398d264e9a" (FusionWebPartWebPart). Original error: ***Failed to load URL 'https://localhost:4321/node_modules/react/dist/react.js' for resource 'react' in component '174429f3-8ff8-4143-8f12-7c398d264e9a' (FusionWebPartWebPart). The file was not found in the server. Make sure that you are running 'gulp serve'. ***INNERERROR: ***Failed to load URL 'https://localhost:4321/node_modules/react/dist/react.js' for resource 'react' in component '174429f3-8ff8-4143-8f12-7c398d264e9a' (FusionWebPartWebPart). The file was not found in the server. Make sure that you are running 'gulp serve'. ***CALLSTACK: Error at SPLoaderError.SPError [as constructor] (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:8390:24) at new SPLoaderError (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:4036:28) at Function.ErrorBuilder.buildErrorWithVerboseLog (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:3789:21) at Function.ErrorBuilder.buildLoadComponentError (https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:3697:21) at https://localhost:4321/temp/workbench-packages/@microsoft_sp-loader/dist/sp-loader-assembly_default.js:6275:47 Vesa Juvonen4.9KViews1like2CommentsCannot See File Type Icon in Document Card from the Fabruic UI-React
I am using the DocumentCard from Fabric-React to create a document library web part using the react framework. Currently my Document Library is mostly working. it looks like this But notice inside of my previews, the mini Icon for the File Type is not displayed. However, if i go into Chrome Dev Tools, and i find the ms-documentCardPreview-icon Div, and i add "Width:25%" the icon will appear. I cannot use CSS to give the ms-DocumentCardPreview-icon div a width, because webpack adds a series of digits to the div name on build. please help me understand why a width is not being applied and how to make it apply so both the icon and the preview image are displayed as in the example provided by microsoft here: https://developer.microsoft.com/en-us/fabric#/controls/web/documentcard4.8KViews0likes3CommentsNext Js as WebPart
Hi there, I have an application that was made using Next Js and my team wants to put it on a share point page, I have been trying to find information to know if this is even possible. I found WebParts but I am not sure if that is compatible with Next Js and I haven't found any resources that could help me with this. Any help will be appreciated. Thanks.3.9KViews0likes1CommentGetting Started with React and SharePoint - From a UX Designer/Developer's Perspective
If you've been keeping watch on the new SharePoint Framework you have undoubtedly read or experienced the dichotomy of extremely basic "Hello World" articles and if not basic, then articles written by hard core-code-ninja programmers. If you’re a Designer, Developer or UX Practitioner trying to make sense of the React and Modern SharePoint Framework universe it can be difficult reconciling these two very different spectra. From a UX Practitioner's standpoint we need to know enough about Development to strategically understand what's possible in Design, while attempting to make a User’s experience better. That middle ground of development and design when focused inside of SharePoint helps to build exciting experiences and promote healthy User Adoption. The goal of this 5-part series is targeted at the hybrid role of Designer, Developer and UX Practitioner in an attempt to navigate through some of the poorly documented and major hurdles of React Development. Part 1 – CSS tricks and working with syntax Part 2 – Integration of third party or legacy plug-ins Part 3 – Images, SVG graphics and Components Part 4 – REST call to a SharePoint List and displaying the results Part 5 – Building a super cool React Modern SharePoint Web Part React SharePoint Modern Framework Web Part – we will be building this in Part 5 of this series. Alright, enough talk let’s get started. Part 1 CSS in React Ok so if you’re like me and have been using traditional CSS for almost 20 years, CSS inside React at first... is a little painful. There is an in-depth blog post written by Agata Krzywda about CSS and React https://codeburst.io/4-four-ways-to-style-react-components-ac6f323da822 detailing almost every situation and use case. The article mentioned by Agata is very helpful for understanding CSS and React, but what the article doesn’t take into account are the real-world syntactical oddities that we run into on a daily basis, which like I’ve mentioned are generally missing from 80% of online React documentation. The SPFX team at Microsoft has done a great job by giving us the SPFX boiler plate webpart that generates the code below. Deciphering the CSS in the SPFX boiler plate has a pretty steep learning curve partially because the boiler plate project hides some key ingredients that if you are not outwardly looking for them, you'll miss out on the learning experience. Example the Office Fabric .css file is buried in the node_modules folder and is not referenced through import in the head of the page... so if you were trying to understand where "ms-bgColor-themeDark" is being referenced its completely confusing... Let's take a look at Lines 11, 14. Line 11: <div className={`ms-Grid-row ms-bgColor-themeDark ms-fontColor-white ${styles.row}`}> Line 14: <div className={"ms-font-1 ms-fontColor-white"}> These two lines show different ways to use CSS in React that mimic 90% of the web at large. Now Let's look at Line 16. Notice there's some different stuff going on here... "styles" is the imported reference to the scss file and "label" is the class name. Line16: <div className={styles.label}> * The big take away here is that CSS in React has multiple ways to use it, and you can choose which works best for you depending on your situation. Below are some extremely useful and hard to find syntactical variations of CSS in React, that go beyond the CSS article written by Agata and that also extend the SPFX boiler plate example from Microsoft. Here are a few super helpful examples of className syntactical combinations Multiple class names with hyphens concatenated together while still referencing the import iconstyles module. className={[iconstyles["glyphicon"], iconstyles["glyphicon-star-empty"]].join(' ')} Entire string of static classes in a string with a variable name inside the string <div className={`ms-Grid-row ms-bgColor-themeDark ms-fontColor-white ${styles.row}`}> Multiple static classes along with a variable name concatenated together className={[`mix`, `all`, item.Category ].join(' ')} Class name as a static string. Notice the use of this ( ` ) not ( ‘ ) or ( “ ) className={`mix`} Class used classically in a variable as larger static string const htmlstring = ` <div class="row mixitup-wrapper"></div>`; This table hopefully saves a fellow Designer, Developer or UX Practitioner some time and effort, I know while I was picking up React each variation of CSS was a watershed moment. In Part 2 of this series we are going to hammer out how to work with third party plug-ins inside React like JQuery, Bootstrap and MixitUp.3.4KViews1like0CommentsSet width for `PivotItem` in Office UI Fabric
I am using Pivot and PivotItem from Office UI Fabric to display my content in tabs. Currently when the tab renders, all the tabs are left aligned. I need to display the tabs with equal width so that they occupy the 100% width of the page. Below is the code for Pivot. <Pivot linkFormat={PivotLinkFormat.tabs} linkSize={PivotLinkSize.large} styles={pivotStyles}> <PivotItem headerText="Foo"> <Label>Pivot #1</Label> </PivotItem> <PivotItem headerText="Bar"> <Label>Pivot #2</Label> </PivotItem> <PivotItem headerText="Bas"> <Label>Pivot #3</Label> </PivotItem> <PivotItem headerText="Biz"> <Label>Pivot #4</Label> </PivotItem> </Pivot> Below is the code that I could figure out to add styles to Pivot. But we do not have styles attribute for PivotItem. const pivotStyles:IPivotStyles = { link: {}, linkContent: {}, linkIsSelected: {}, text: {}, icon: {}, count: {}, root: { //background: DefaultPalette.greenDark } }; How can I apply style to PivotItem so that I can add width to it?2.2KViews0likes0CommentsBest JS framework(Angular/React/Vue) to use in SharePoint 2013
Hi, We have tools (Basically CRUD operations in multiple lists across sites/site collections. Handles large amount of data and has lots of business functionalities/logic) that were built using jQuery and Datatables.js. We are planning to rebuild in 2013. Visual Studio/ server side coding is not allowed. Can anyone suggest which JavaScript framework (Angular Js1.x, Angular 2+, React, Vue/ Others) is best to use in SharePoint 2013? Difficult to get Node.JS/NPM/CLI on DEV environment. we have tried a PoC in Angular 4 using SystemJs-Manual mapping concept. But not sure how bundling and future upgrade will be if CLI/NPM is not used. Any suggestions please? Thanks, Puli2.1KViews1like1Commentwhere to add PnPTelemetry code in SPFX PnP solution
Hi all, I need to include PnP Telemetry in my code. I am working on SPFX React based solution. I haven't used it before. Can you guide me where to use below lines of code, in Constructor or render method? const telemetry = PnPTelemetry.getInstance(); telemetry.optOut(); This is one of app deployment requirement, haven't found much documentation about it. Will apricate your help on this.1.8KViews0likes0CommentsObtaining full HTML of a SPO Site Page programatically
Hi I need to obtain the full HTML of a SPO Site Page programatically. I have a SPFx web part showing latest published site pages. So far I tried with PNPJS (ClientSidePage.fromFile) with Search (CanvasContent1OWSHTML) and with SP REST API (getbytitle('Site Pages')/Items?$select=CanvasContent1) All of them seem to return some HTML which is not the full page. Is there a way to obtain the full page without using iFrame? Greeitings, George1.5KViews0likes0CommentsUtilising Office UI Grid with React based Sharepoint Web Parts
I have been tying to utilise the https://developer.microsoft.com/en-us/fabric#/styles/layout with a React Sharepoint Web Part. It seems these are not fully compatible, as the breakpoints for the grid are browser width scoped and not Sharepoint column layout scoped. The result of this is that the grid can be utilised in a web part if a single column view is used on a page, but not if multiple columns are used. If this is correct, are there any alternatives to dealing with columns and layouts for the web parts that allow for scoping to the page columns rather than the browser width? I have attached two screenshots showing a single column view on mobile, with the grid working correctly, but an incorrect layout on desktop when multiple columns are used.1.4KViews0likes0Commentsnot able to view the files from sharepoint in react file viewer
when i try the react file viewer from this repo https://codesandbox.io/s/react-file-reader-forked-3oszl?file=/src/index.js i am able to view files from online samples but not sharepoint url, when i do so i am getting the cros error Access to XMLHttpRequest at 'https://sharepoint.com/sites/DevL/Clients/AVM001103/Forms/AllItems.aspx?id=%2Fsites%2FDevL%2FClients%2FAVM001103%2FResults%2Edocx&parent=%2Fsites%2FDevL%2FClients%2FAVM001103' from origin 'https://w2hpd.csb.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.1.1KViews0likes0Comments