Posts

Create a lean React Solution using Typescript

 Make sure you have node and npm installed Directory Setup 1. npm run init 2. create public and src folder 3. Add index.html in public folder 4. Add index.tsx in src folder Add Dependencies npm install react react-dom Add Dev Dependencies npm install typescript webpack webpack-cli webpack-dev-server ts-loader html-webpack-plugin  --save-dev  npm i --save-dev @types/react-dom typed-scss-modules  Add Configuration and Code Add code to src\index.tsx https://github.com/sagarpandey88/templates/blob/main/typescript-react/src/index.tsx Add webpack.config.js https://github.com/sagarpandey88/templates/blob/main/typescript-react/webpack.config.js Add tsconfig.json https://github.com/sagarpandey88/templates/blob/main/typescript-react/tsconfig.json Run the code npm run build npm run start

Session Storage Methods with Expiry

We often need to cache the data in sessionStorage with an expiration timeout.  Session Storage doesn't provide an expiration which is the case with cookies   As cookies allows only 4-5kb of datastorage. sessionStorage allows approx. 5MB of data storage.  Below are some handy method for session storage with expiration.

Usecontext React Simple Example

Have recently bumped upon a very nice and simple example to use UseContext in React to share variable and methods across all the components. Reference Link

Register Certificate as Trusted Token Issuer SharePoint 2013

When in need to register a certificate to SharePoint Trusted Token Issuer execute below powershell command in SharePoint Management Shell. In case existing ones needed to be deleted then use below script to delete all.

SharePoint JSOM Nested Include Properties

Hi All, Sometimes we need to get properties which are nested inside of Listitem and we wonder will it be feasible to make multiple queries for the same. So this scenarios usually occurs when you have to get a set of listitems which are folder and we need to get folder properties of the folder. So you can query it using below method. Just add the sub properties in Include tag

Document Set behaving like Folder

Hi All, There is a bug in SharePoint Javascript API to create document sets. They dont behave like document sets unless you update the ProgId of the folder. Below is the code to fix it.

Replace all occurence of String in JavaScript

Hi All, I came across an issue in JavaScript where i was not able to replace all the occurrences of a string in another string. A simple string.replace would only replace the first occurence. str.replace("hello", 'hi'); We can make a small tweak in the existing code and make it work.Below is an example. str.replace(new RegExp('hello', 'g'), 'hi');