Sunday 21 August 2016

First SPFx webpart: Get/Set a single value userprofile property in SharePoint

This post is now out of date after the release of SharePoint Framework GA version. Please refer to one of my other posts which have been updated post GA:

1) Making a POST request to SharePoint from an SPFx webpart
2) Batch REST requests in SharePoint Framework (SPFx) using SPHttpClientBatch
3) Working with the REST API in SharePoint Framework (SPFx)
4) Using Redux Async Actions and ImmutableJS in SharePoint Framework

Original Post follows:

So the Developer preview of the SharePoint Framework was released last week and I decided to get my hands dirty right away. This is a webpart I created just to get a hang of things and to learn the key concepts of the SharePoint Framework.

The code is on GitHub:

Since I had not worked with React a lot, I decided to choose it as my JS framework.

Things I managed to wrap my head around while creating this simple webpart:

1) How to create a SPFx webpart with React as the JS framework.

2) How to talk to SharePoint from within the SPFx webpart with context.httpClient.get and

4) Creating reactive as well as non reactive webpart properties

5) The new _spClientSidePageContext object which contains heaps of context data. According to the wiki, properties of this object will be deprecated and moved under the Context object of the webpart.

(For now, I had to manually create an ambient declaration for this object but hopefully soon, the need for this will go away as it will be moved in the Context object)

6) Office UI Fabric and React Components for Office UI fabric

Since lots of these things were new to me, you might find some bugs/mistakes/horrors in the code so apologies for that in advance. Don't forget to leave a comment and I will be happy to update my code.


1 comment:

Deepu Nair said...

Nice. Looking forward for more :)