Here are the steps to create a React web part:
1. Scaffold a new React web part project:
```
yo @microsoft/sharepoint
```
2. When prompted, select the following:
- Use the current folder for where to place the files
- WebPart as the client-side component type
- Select React as the JavaScript framework
3. This will scaffold all the necessary files and setup React in your project.
4. Import React and ReactDOM in your web part file:
```js
import * as React from 'react';
import * as ReactDom from 'react-dom';
```
5. Create a simple React component:
3. Bootcamp Outline
ī Session 1
ī Getting Started
ī O365 Developer Program
ī Tenant Setup
ī Client Setup
ī Intro to SPFx
ī Session 2
ī Building You First Web Part
ī Scaffolding
ī Building
ī Deployment
ī Pulling Data from SharePoint
ī Intro to PnP-JS
ī Intro to PnP-JS
ī Session 3
ī Intro to React
ī Rebuild Part Using React
ī Intro to Office UI Fabric
ī Text Box
ī Button
ī Creating New Items via PnP
ī Session 4
ī SPFx in Teams
ī Building a Package for Teams
ī Creating Teams Tab
4. About Me
ī SharePoint Collaboration Director @ SoHo Dragon - NYC
ī Branding & Developer for SharePoint / Office 365
ī Focused on the UI side of things
ī Community Involvement
ī Speaker [Branding & Front End Development]
ī NJ SharePoint User Group Organizer
ī SharePoint Saturday NYC Organizer
ī NJ & NYC Global Office 365 Dev Bootcamp Organizer 2017
ī NJ Azure Bootcamp Organizer
ī SharePoint Saturday NJ Organizer [2013-2014]
ī My SharePoint Blog
ī Git Hub [corp directory controls / o365 sticky footer / bootstrap navigation]
Twitter: @_tomdaly_
6. Bootcamp Outline
ī Session 1
ī Getting Started
ī O365 Developer Program
ī Tenant Setup
ī Client Setup
ī Intro to SPFx
ī Session 2
ī Building You First Web Part
ī Scaffolding
ī Building
ī Deployment
ī Pulling Data from SharePoint
ī Intro to PnP-JS
ī Intro to PnP-JS
ī Session 3
ī Intro to React
ī Rebuild Part Using React
ī Intro to Office UI Fabric
ī Text Box
ī Button
ī Creating New Items via PnP
ī Session 4
ī SPFx in Teams
ī Building a Package for Teams
ī Creating Teams Tab
7. Office 365 Developer Subscription
ī Sign up â Online, FREE [Required Live Account]
ī https://developer.microsoft.com/en-us/office/dev-program
ī Starting in April 2019, we offer renewable 90-day subscriptions
ī What's included in the developer subscription?
ī Office 365 E3 â 25 User License
ī SharePoint, Teams âĻ. everything else
9. Create App Catalog Site
ī Go to the Classic SharePoint Admin Center by entering the following URL in your browser.
Replace yourtenantprefix with your Office 365 tenant prefix.
ī https://yourtenantprefix-admin.sharepoint.com
ī In the left sidebar, select the Classic Features > apps menu item, and then select app catalog.
ī Select OK to create a new app catalog site.
ī On the next page, enter the following details:
ī Title: Enter app catalog.
ī Web Site Address suffix: Enter your preferred suffix for the app catalog; for example: apps.
ī Administrator: Enter your username, and then select the resolve button to resolve the username.
ī Select OK to create the app catalog site.
ī SharePoint creates the app catalog site, and you are able to see its progress in the SharePoint admin
center.
https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-
tenant#to-create-an-app-catalog-site
10. Create Test Site Collection
ī Go to the SharePoint Admin Center by entering the following URL in your browser.
Replace yourtenantprefix with your Office 365 tenant prefix.
ī https://yourtenantprefix-admin.sharepoint.com/_layouts/15/online/AdminHome.aspx
ī In the left sidebar, select Sites > Active Sites.
ī In the toolbar, select Create.
ī In the Create a site dialog, select Communication Site.
ī In the panel that appears, enter the following details:
ī Choose a design: choose blank.
ī Site name: Enter a title for your site; for example: Test Site.
ī Site owner: Specify the name / email address of the site owner.
ī Select Finish to create the site collection.
11. Using Existing Tenant?
ī Donât want to pollute global app catalog
ī We can do site collection based app catalog to isolate your developments
Connect-SPOService -Url https://{TENANT}-admin.sharepoint.com
$site = Get-SPOSite https://{TENANT}.sharepoint.com/sites/{SITE}
Add-SPOSiteCollectionAppCatalog -Site $site
ī See Team Member for assistance
ī https://docs.microsoft.com/en-us/sharepoint/dev/general-development/site-collection-app-catalog
13. Software / Tooling
ī Install NodeJS
ī Install NodeJS LTS version 10
ī Install a code editor
ī Visual Studio Code
ī Install Yeoman and gulp
ī npm install -g yo gulp
ī Install Yeoman SharePoint generator
ī npm install -g @microsoft/generator-
sharepoint
ī Trusting the self-signed developer certificate
ī Do this after creating your first project
ī gulp trust-dev-cert
ī Install Google Chrome
ī optional but recommended
ī Extensions
ī SP Editor
ī React Developer Tools
ī Internet Explorer 11
ī Not Good for Web Development
https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-
environment
14. Node.JS
As an asynchronous event-driven JavaScript
runtime
âĻruns JavaScript files on your computer
Get version 10.x for SPFx Development!
https://nodejs.org/dist/latest-v10.x/
15. Node Package Manager
ī Online repository of packages
ī Allows for quick installation into your projects
ī Packages developed by 3rd party
individuals/teams on GitHub
ī âĻsimilar to Android/iOS app store but for
JavaScript.
16. Yeoman
ī âyoâ scaffolds out a new application
ī Writing your build configuration (e.g Gulpfile)
ī Pulling in relevant build tasks and package
manager dependencies (e.g npm)
ī Uses âgeneratorsâ which define the scaffolding
workflow
ī âĻbased on a âtemplateâ, creates directories,
sets up project files and downloads
dependencies
17. Gulp
ī A toolkit to automate & enhance your
workflow
ī Automate slow, repetitive workflows and
compose them into efficient build pipelines.
ī âĻtask runner to do very simple tasks in parallel
or series
18. Webpack
ī Used to compile JavaScript modules.
ī Handles dependencies between modules
automatically
ī Transpiles Code
ī âĻtakes all your files + dependencies [npm
packages] and creates 1 JavaScript file
19. TypeScript
ī Open Source language developed
by Microsoft
ī Superset of JavaScript
ī Compiles to plain JavaScript
ī Brings strong type checking /
compile-time error checks
ī âĻmakes JavaScript more like C#,
typing, object oriented
programming concepts classes,
interfaces, inheritance
21. SharePoint Framework (SPFx)
ī Page / Web Part model that provides full support for client-side SharePoint development
ī Easy integration with SharePoint data
ī Support for Open Source tooling
ī âTheâ customization model for Office 365
ī Support for SharePoint 2016 Feature Pack 2, SharePoint 2019, & Office 365
22. Key Features
ī It runs in the context of the current user and connection in the browser.
ī NO iframes(JavaScript is embedded directly to the page).
ī The controls are rendered in the normal page DOM.
ī It is framework-agnostic. You can use any JavaScript framework that you like: React, Handlebars,
Knockout, Angular, and more.
ī The toolchain is based on common open source client development tools such as npm,
TypeScript, Yeoman, webpack, and gulp.
ī End users can use SPFx client-side solutions that are approved by the tenant administrators (or
their delegates) on all sites, including self-service team, group, or personal sites.
ī SPFx web parts can be added to both classic and modern pages.
23.
24. Session 2
First Look at SPFx - Building your first web part, talking to SharePoint via REST & PnP-JS
25. Bootcamp Outline
ī Session 1
ī Getting Started
ī O365 Developer Program
ī Tenant Setup
ī Client Setup
ī Intro to SPFx
ī Session 2
ī Building You First Web Part
ī Scaffolding
ī Building
ī Deployment
ī Pulling Data from SharePoint
ī Intro to PnP-JS
ī Intro to PnP-JS
ī Part 3
ī Intro to React
ī Rebuild Part 2 using React
ī Intro to Office UI Fabric
ī Text Box
ī Button
ī Creating New Items via PnP
ī Part 4
ī SPFx in Teams
ī Building a Package for Teams
ī Creating Teams Tab
27. Create Web Part Project
ī Create a new project directory in your favorite location.
ī md helloworld-webpart
ī Go to the project directory.
ī cd helloworld-webpart
ī Create a new HelloWorld web part by running the Yeoman SharePoint Generator.
ī yo @microsoft/sharepoint
28. Create Web Part Project (cont)
ī When prompted:
ī Accept the default helloworld-webpart as your solution name, and then select Enter.
ī Select SharePoint Online only (latest), and select Enter.
ī Select Use the current folder for where to place the files.
ī Select N to allow the solution to be deployed to all sites immediately.
ī Select N on the question if solution contains unique permissions.
ī Select WebPart as the client-side component type to be created.
29. Create Web Part Project (cont)
ī The next set of prompts ask for
specific information about your web
part:
ī Accept the default HelloWorld as
your web part name, and then
select Enter.
ī Accept the default HelloWorld
description as your web part
description, and then select Enter.
ī Accept the default No JavaScript
web framework as the framework
you would like to use, and then
select Enter.1
30. Create Web Part Project (cont)
ī At this point, Yeoman installs the
required dependencies and
scaffolds the solution files along
with the HelloWorld web part. This
might take a few minutes.
ī When the scaffold is complete, you
should see the following message
indicating a successful scaffold.
31. Preview the web part
ī Enter the following command in the
console to open VS Code:
ī code .
ī Enter the following to open the
Terminal in VS Code
ī CTRL + `
ī Enter the following command in the
terminal to build and preview your
web part:
ī gulp serve
32. What is Happening?
ī SharePoint client-side development tools use gulp as the task runner to handle build process
tasks such as:
ī Bundling and minifying JavaScript and CSS files.
ī Running tools to call the bundling and minification tasks before each build.
ī Compiling SASS files to CSS.
ī Compiling TypeScript files to JavaScript.
33. SharePoint Workbench
ī Developer design
surface that enables
you to quickly preview
and test web parts
without deploying them
in SharePoint.
34. Add Your Web Part
ī To add the HelloWorld web part, select the add icon (this icon
appears when you mouse hovers over a section as shown in the
previous image).
ī This opens the toolbox where you can see a list of web parts
available for you to add. The list includes the HelloWorld web
part as well other web parts available locally in your
development environment.
35. Add Your Web Part (cont)
ī Select HelloWorld to add the web
part to the page.
38. Packaging the Web Part
ī If gulp serve is still running, stop it from running by hitting, ctrl + C
ī In the console window, enter the following command to package your client-side solution that
contains the web part:
ī gulp clean
ī gulp build --ship
ī gulp bundle --ship
ī gulp package-solution â-ship
For dev builds you donât need the âship but then you must be running gulp serve
Simple Build Script for the SharePoint Framework
39. Deploy to App Catalog
ī Go to your site's app catalog.
ī Upload or drag and drop
the helloworld-webpart.sppkg to
the app catalog.
40. Deploy to App Catalog (cont)
ī This deploys the client-side
solution package. Because this is
a full trust client-side solution,
SharePoint displays a dialog and
asks you to trust the client-side
solution to deploy.
ī Select Deploy.
ī Notice that you can see if there's
any exceptions or issues in the
package by looking the App
Package Error Message column in
the app catalog.
42. Install App in Site
ī Go to your developer site
collection or site collection
which you want to use for
testing
ī Select the gears icon on the
top nav bar on the right, and
then select Add an app to go
to your Apps page.
ī In the Search box,
enter helloworld, and select
Enter to filter your apps.
43. Install App in Site (cont)
ī Select the helloworld-
webpart-client-side-
solution app to install the
app on the site.
ī The client-side solution
and the web part are
installed on your
developer site.
44. Add Web Part to Modern Page
ī In your browser, go to your site
where the solution was just
installed.
ī Select the gears icon in the top
nav bar on the right, and then
select Add a page.
ī Edit the page.
ī Open the web part picker and
select your HelloWorld web
part.
47. Create a Custom List
ī Navigate to your site
ī Gear > Add an app > Custom List
ī Name: Test
ī Make at least 2 items
48. Live Development
ī Enter the following command in the console to build and
preview your web part:
ī gulp serve
ī On the Page with the webpart add the following to the end of
the url
ī ?loadSPFX=true&debugManifestsFile=https://localhost
:4321/temp/manifests.js
ī BONUS: use SP-Editor [Chrome Extension] to load debug url
59. What is PnP-JS?
ī PnP-JS is a collection of fluent
libraries for consuming SharePoint,
Graph, and Office 365 REST APIs in
a type-safe way.
ī Benefits:
ī Intellisense
ī Typing
ī Asynchronous
ī Caching
ī Clear Code Intent
ī Abstraction
ī Open Source
60. Getting Started
ī Install
ī npm install
@pnp/logging
@pnp/common
@pnp/odata @pnp/sp
@pnp/graph --save
ī Establish Context
ī See Right Image
Stop any running gulp serve before installing
67. Bootcamp Outline
ī Session 1
ī Getting Started
ī O365 Developer Program
ī Tenant Setup
ī Client Setup
ī Intro to SPFx
ī Session 2
ī Building You First Web Part
ī Scaffolding
ī Building
ī Deployment
ī Pulling Data from SharePoint
ī Intro to PnP-JS
ī Intro to PnP-JS
ī Session 3
ī Intro to React
ī Rebuild Part 2 using React
ī Intro to Office UI Fabric
ī Text Box
ī Button
ī Creating New Items via PnP
ī Session 4
ī SPFx in Teams
ī Building a Package for Teams
ī Creating Teams Tab
69. What is React?
ī JavaScript library for building user interfaces
ī At a minimum, know this:
ī Components: These are the building blocks of your app. You want to make them as modular as possible.
ī State: internal data, that when changed caused the UI to re-render. You own this data.
ī Props: data / functions, passed to a component. You donât own this data.
ī Life Cycle Methods: functions that do things at certain points
71. Create React Web Part Project
ī Create a new project directory in your favorite location.
ī md helloworld-webpart-2
ī Go to the project directory.
ī cd helloworld-webpart-2
ī Create a new HelloWorld web part by running the Yeoman SharePoint Generator.
ī yo @microsoft/sharepoint
72. Create Web Part Project (cont)
ī When prompted:
ī Accept the default helloworld-webpart-2 as your solution name, and then select Enter.
ī Select SharePoint Online only (latest), and select Enter.
ī Select Use the current folder for where to place the files.
ī Select N to allow the solution to be deployed to all sites immediately.
ī Select N on the question if solution contains unique permissions.
ī Select WebPart as the client-side component type to be created.
73. Create Web Part Project (cont)
ī The next set of prompts ask for
specific information about your web
part:
ī Accept the default HelloWorld as
your web part name, and then
select Enter.
ī Accept the default HelloWorld
description as your web part
description, and then select Enter.
ī Select React as the framework
you would like to use, and then
select Enter.1
74. Open with Visual Studio Code
ī Type the following command:
ī code .
ī Use the VS Code console to run
gulp commands
75. Create Web Part Project (cont)
ī At this point, Yeoman installs the
required dependencies and
scaffolds the solution files along
with the HelloWorld web part. This
might take a few minutes.
ī When the scaffold is complete, you
should see the following message
indicating a successful scaffold.
76. Next Steps
ī Open VS Code
ī Build / Bundle / Package
ī Deploy to SharePoint App Catalog
ī Add App to SharePoint Site
ī Add to Page
77. Add PnP-JS to Project
ī Install
ī npm install
@pnp/logging
@pnp/common
@pnp/odata @pnp/sp
@pnp/graph --save
ī Establish Context in
HelloWorldWebPart.ts
ī See Right Image
86. Intro to Office UI Fabric
The Design Language of Microsoft Products
87. What is the Office UI Fabric?
ī Microsoftâs UX Framework to create seamless experiences in Microsoft
products
ī Two Flavors Available
ī Fabric React â open-source React front-end framework designed to build
experiences that fit seamlessly into a broad range of Microsoft products.
ī Fabric Core â open-source collection of CSS classes and Sass mixins that give you
access to Fabric's colors, animations, fonts, icons and grid.
Think of it as a bunch of styles and a bunch of controlsâĻ similar to bootstrap
115. Bootcamp Outline
ī Session 1
ī Getting Started
ī O365 Developer Program
ī Tenant Setup
ī Client Setup
ī Intro to SPFx
ī Session 2
ī Building You First Web Part
ī Scaffolding
ī Building
ī Deployment
ī Pulling Data from SharePoint
ī Intro to PnP-JS
ī Intro to PnP-JS
ī Session 3
ī Intro to React
ī Rebuild Part 2 using React
ī Intro to Office UI Fabric
ī Text Box
ī Button
ī Creating New Items via PnP
ī Session 4
ī SPFx in Teams
ī Building a Package for Teams
ī Creating Teams Tab
117. Teams Folder
ī Starting with the SharePoint Framework v1.8, scaffolding
will also include additional ./teams folder
ī Teams folder contains the following two files:
ī [componentId]_color.png - Default small picture for a
tab
ī [componentId]_outline.png - Default large picture for
a tab
ī These images will be used as icons in Microsoft Teams.
ī Teams Manifest â Defines the app, by default not there
SharePoint will create it for you!@
ī https://docs.microsoft.com/en-
us/sharepoint/dev/spfx/web-parts/get-started/using-
web-part-as-ms-teams-tab
125. Rebuild
ī If gulp serve is still running, stop it from running by hitting, ctrl + C
ī In the console window, enter the following command to package your client-side solution that
contains the web part:
ī gulp clean
ī gulp build --ship
ī gulp bundle --ship
ī gulp package-solution â-ship
Simple Build Script for the SharePoint Framework
133. Resources
All Content comes from the
Official Microsoft Documentation
Code / Cheat Sheets - Part 2, 3
& 4 â all on github
https://github.com/tom-
daly/demos/tree/master/m365-
bootcamp
Slides
https://www.slideshare.net/tomm
daly/m365-global-developer-
bootcamp-2019-194066436
134. Voitanos On-Demand Training
ī The best SPFx training resource â hands down,
always updated, on demand.
ī ~$750 for the Ultimate Package. Worth It!
ī Taught by Andrew Connell, 15+ year MVP in
SharePoint / Office 365
īâUnderstanding the SPFx Dev Toolchainâ
email course [FREE]
īMastering the SharePoint Framework On
Demand