Skip to content

Commit fcc25e1

Browse files
committed
Updates on the Fabric usage tutorial to simplify the process with the latest SPFx versions
1 parent 8c4e5f4 commit fcc25e1

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

docs/spfx/web-parts/get-started/use-fabric-react-components.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ You can also follow these steps by watching this video on the SharePoint PnP You
4747
* Accept the default **documentcardexample-webpart** as your solution name, and select Enter.
4848
* Select **SharePoint Online only (latest)**, and select Enter.
4949
* Select **Use the current folder** for where to place the files.
50-
* Select **N** to require the extension to be installed on each site explicitly when it's being used.
51-
- Select **N** on the question if solution contains unique permissions.
50+
* Select **y** to require the extension to be installed on each site explicitly when it's being used.
51+
- Select **N** on the question if solution contains unique permissions.cd
5252
* Select **WebPart** as the client-side component type to be created.
5353

5454
5. The next set of prompts ask for specific information about your web part:
@@ -59,29 +59,21 @@ You can also follow these steps by watching this video on the SharePoint PnP You
5959

6060
At this point, Yeoman installs the required dependencies and scaffolds the solution files. This might take a few minutes. Yeoman scaffolds the project to include your DocumentCardExample web part as well.
6161

62-
6. When initial scaffolding is completed, you may need to explicitly add a version of office-ui-fabric-react to your package.json file. If you are using version 1.8.2 or later of the generator, you won't need to worry about this, but older versions will. Open your package.json file, and look for an entry for 'office-ui-fabric-react'. If there isn't one, add the following entry in your dependencies section
63-
64-
```
65-
"office-ui-fabric-react": "5.132.0"
66-
```
67-
followed by the following command at your command prompt.
68-
```
69-
npm install
70-
```
62+
Starting from 1.8.2 version, Yeoman will automatically associate the recommended `@microsoft/sp-office-ui-fabric-core` package version to your solution when you select the **React** as the framework.
7163

7264
> [!NOTE]
73-
> Starting with SharePoint Framework 1.8, you can use either Office UI Fabric version 5 or version 6. In this case we are using specifically Office UI Fabric version 5.132.0, so we are adding the needed dependency on it. If you would be using Office UI Fabric version 6.x, you'd also need to update the used TypeScript version of the solution. To use fabric 6, you need to be on at least rush-stack-compiler-2.9 . The default project created with version 1.8.2 for SharePoint Online will use rush-stack-compiler-2.9 and fabric 6 (and won't need the step to add office-ui-fabric-react to your package.json file). Previous versions use either rush-stack-compiler 2.7 or a build system that is locked to typescript 2.4. In those cases, you'll need to reference fabric 5.132.0. If you are targeting on-prem, you will also want to use fabric 5.132.0.
65+
> Starting with SharePoint Framework 1.8, you can use either Office UI Fabric version 5 or version 6. In this case we are using specifically Office UI Fabric version 5.132.0, so we are adding the needed dependency on it. If you would be using Office UI Fabric version 6.x, you'd also need to update the used TypeScript version of the solution. To use fabric 6, you need to be on at least rush-stack-compiler-2.9. The default project created with version 1.8.2 for SharePoint Online will use rush-stack-compiler-2.9 and fabric 6 (and won't need the step to add office-ui-fabric-react to your package.json file). Previous versions use either rush-stack-compiler 2.7 or a build system that is locked to typescript 2.4. In those cases, you'll need to reference fabric 5.132.0. If you are targeting on-prem, you will also want to use fabric 5.132.0.
7466
7567

76-
7. Next, enter the following to open the web part project in Visual Studio Code:
68+
6. Next, enter the following to open the web part project in Visual Studio Code:
7769

7870
```
7971
code .
8072
```
81-
73+
8274
You now have a web part project with the React framework.
8375

84-
8. Open **DocumentCardExampleWebPart.ts** from the **src\webparts\documentCardExample** folder.
76+
7. Open **DocumentCardExampleWebPart.ts** from the **src\webparts\documentCardExample** folder.
8577

8678
As you can see, the `render` method creates a react element and renders it in the web part DOM.
8779

@@ -93,10 +85,13 @@ You can also follow these steps by watching this video on the SharePoint PnP You
9385
description: this.properties.description
9486
}
9587
);
88+
89+
ReactDom.render(element, this.domElement);
90+
}
9691
```
97-
98-
9. Open **DocumentCardExample.tsx** from the **src\webparts\documentCardExample\components** folder.
99-
92+
93+
8. Open **DocumentCardExample.tsx** from the **src\webparts\documentCardExample\components** folder.
94+
10095
This is the main react component that Yeoman added to your project that renders in the web part DOM.
10196

10297
```HTML
@@ -200,6 +195,9 @@ Copy the following images to your **src\webparts\documentCardExample\components*
200195
* [icon-ppt.png](https://github.com/SharePoint/sp-dev-docs/tree/master/assets/icon-ppt.png)
201196
* [document-preview.png](https://github.com/SharePoint/sp-dev-docs/tree/master/assets/document-preview.png)
202197

198+
> [!NOTE]
199+
> In the code we were referencing these images using relative path from the root ___location. As your reference the images in the code, it will cause them to be included in the sppkg solution package as long as you have the `includeClientSideAssets` set as `true` in the **package-solution.json** file.
200+
203201
## Preview the web part in Workbench
204202

205203
1. In the console, enter the following to preview your web part in Workbench:

0 commit comments

Comments
 (0)