sp-dev-fx-webparts/samples/react-redux-async-immutablejs
Hugo Bernier 7e97daab76 Added more contributions 2023-03-15 01:23:34 -04:00
..
.devcontainer
assets
config
src/webparts/demo
typings
.editorconfig
.gitattributes
.gitignore
.npmignore
.yo-rc.json
README.md
gulpfile.js
package-lock.json
package.json
tsconfig.json
tslint.json

README.md

page_type products languages extensions
sample
office-sp
javascript
typescript
contentType technologies platforms createdDate
samples
SharePoint Framework
react
8/1/2017 12:00:00 AM

SharePoint Framework web part sample using React, Redux and ImmutableJS

Summary

SharePoint Framework web part which uses Redux to maintain a single state for the entire application and ImmutableJS to create performant state trees.

Redux AJAX actions are used together with the SharePoint REST API to display lists in your site. You can also add a new list to the site from this web part.

More details in my post here: Using Redux Async Actions and ImmutableJS in SharePoint Framework

Compatibility

⚠️ Important
Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.
Refer to https://aka.ms/spfx-matrix for more information on SPFx compatibility.

SPFx 1.1.0 Node.js v6 Compatible with SharePoint Online Compatible SharePoint 2019 Compatible with SharePoint 2016 (Feature Pack 2) Local Workbench Compatible Hosted Workbench Compatible Compatible with Remote Containers

Applies to

Contributors

Version history

Version Date Comments
1.0 July 11, 2017 Initial release

Minimal Path to Awesome

  • Clone this repository
  • in the command line run:
    • npm install
    • gulp serve
    • Open the SharePoint Online version of the workbench: /_layouts/15/workbench.aspx

This sample can also be opened with VS Code Remote Development. Visit https://aka.ms/spfx-devcontainer for further instructions.

Why Redux and ImmutableJS

Every Redux action creates a copy of the state, changes the required properties in the copy and then returns the copy as a new state. This prevents bugs where the state is changed unknowingly.

On the other hand, this can also be performance intensive as for changing only a single element, we have to copy the entire state tree in memory. Fortunately, ImmutableJS comes to the rescue here.

Using ImmutableJS, we can create new state trees in memory without duplicating the elements which are unchanged. When you create a new state object using ImmutableJS, the new object still points to the previous memory locations of unchanged elements. Only the properties which are changed are allocated new memory locations.

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.