Friday, June 5, 2020
How we can use SharePoint framework client side webpart in classic pages?
What is Redux?
- Redux is a predictable state container for JavaScript applications.
- It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test.
- Simply put, Redux is a state management tool. While it’s mostly used with React, it can be used with any other JavaScript framework or library.
- It is lightweight at 2KB (including dependencies), so you don’t have to worry about it making your application’s asset size bigger.
- With Redux, the state of your application is kept in a store, and each component can access any state that it needs from this store.
Thursday, June 4, 2020
What is the difference between local workbench and Actual site workbench?
- One is outside of SharePoint, hosted locally on the development machine that runs offline without SharePoint access and SharePoint data.
- This allows the team and designers to build and design solutions with mock or fake data to focus on the user interface.
- This enables us to quickly test the web part without deploying in SharePoint.
- This includes the client-side page and the client-side canvas in which we can add, delete, and test our web part in the development phase.
- When we execute the “gulp serve” command the local workbench starts. This command executes a series of gulp tasks to create a local, node-based HTTPS server on localhost:4321 and launches our default browser to test web parts from our local dev environment.
How you handle multiple textbox values on single handler in react js?
How we can get current site url in Sharepoint framework?
Why we use constructor() and super() in class?
- The constructor is a method that’s automatically called during the creation of an object from a class.
- It can be used to bind event handlers to the component.
- It can be used for initializing the local state of the component.
- The constructor() method is fired before the component is mounted.
- When you call the super() method, it calls the constructor of the parent class which in the case of a React component is React.Component
super() is called inside a react component only if it has a constructor. For example, the below code doesn't require super:
class App extends React.component {
render(){
return <div>Hello { this.props.world }</div>;
}
}
However if we have a constructor then super() is mandatory:
class App extends React.component {
constructor(){
console.log(this) //Error: 'this' is not allowed before super()
}
}
The reason why this cannot be allowed before super() is because this is uninitialized if super() is not called. However even if we are not using this we need a super() inside a constructor because ES6 class constructors MUST call super if they are subclasses. Thus, you have to call super() as long as you have a constructor. (But a subclass does not have to have a constructor).
We call super(props) inside the constructor if we have to use this.props, for example:
class App extends React.component{
constructor(props){
super(props);
console.log(this.props); // prints out whatever is inside props
}
}
What is props and state in react
Props
- The props are read-only properties we set values to when we call our React component.
- They are a way to transfer information from the parent component to the child.
- We can also use them in your React component to control how it behaves in different situations – when different kind of data is passed down to it.
- The state can also be used for controlling, e.g., how our component is rendered.
- What makes state different from props is that we can change its values.
- We typically initialize state with null values in the constructor and later change the values when something happens in the component to reflect that change – the new state of the component.



