Building a web part
Git branch
This section uses the https://github.com/PacktPublishing/Mastering-SharePoint-Development-with-the-SharePoint-Framework-/tree/chapter5/building-a-webpart Git branch from the repository.
As we saw in Chapter 1, an SPFx web part can be consumed in many ways, such as inside a SharePoint page, as a Teams tab application, or even a Teams message extension. For the rest of this section, we’ll focus on the scenario where the web part needs only to be displayed on SharePoint pages.
At this point, we assume your developer environment is set up correctly and you are ready to begin. The solution is made using SPFx v1.19.0.
Creating the solution
Because the web part is the first component we create, the very first step is to create the SPFx solution at the same time using the Yeoman generator. From a new Packt.Solutions.ProductManagement folder, run the following command:
yo @microsoft/sharepoint --component-type "webpart" --component...
 
                                             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                