React is unopinionated and may be that is a problem. React component has a state. The state within the component get a bit messy for any medium-sized application. State management libraries like Flux, Redux or Mobx are available to manage state. The Flux pattern enables uni-directional data flow in a React application. The article explains the various patterns available to manage state and control data flow.…
Year: 2016
Last week, I made two mistakes with my Redux code.
Mistake #1: deepClone Redux state
The state within the reducer is immutable. That is, the old state should never be changed. To ensure that the old state never gets changed, I got a “cool idea”. Do a deepClone of the entire state. So, my reducer code looked like:
case ActionType.SomeAction: { const newState = deepCopy(state); newState.someArray.push('abc');…
UPDATE (Jan 15, 2019):
A better article for Webpack v4 is published.
The article explains how to do a minimal scaffolding of React application using Webpack.
- Setup Git.
- Setup npm.
- Install packages.
- Setup babel.
- Setup Webpack.
- Define entry.
- Include bundle.
- Run application.
Setup Git
Setup a git repo as follows.
git init git remote add origin <remoteurl
Setting up a git repo is optional if you are only doing a demo.…
Meteor is a JavaScript framework built on top of NodeJS to create web applications and mobile apps based on Cordova. Bootstrap is a popular stylesheet theme maintained by core developers from Twitter. This article explains how to customise Bootstrap within a Meteor application.
Bootstrap styles are written in Less. Less is similar to SASS. It allows to reuse variables and styles.…
Over the last six months, I am working intensely with the React ecosystem. I developed a web application and two native apps from the scratch. I have also been working on a few existing applications for start-ups based in New York, Spain, and Sweden. The move away from .NET has been amazing. I have never learnt something this fast. And I have never been so passionate about JavaScript and ES6 like I am now.…
The article provides a quick guide to understanding Entity Framework.
Why Entity Framework?
Entity Framework is an ORM layer which implements the Unit of Work pattern. The library keeps a track of all changes made to database entities. It saves all changes in a single transaction.
DbContext
class keeps track of the entities. The SaveChanges
method saves multiple updates in a single transaction.…
ASP.NET Web API has an oAuth2 server. There is an endpoint, /token
. Posting to the token endpoint with login credentials gives an access token. For authorising the user, pass the access token to all other endpoints exposed by the API.
Role based security restricts access to various parts of the API based on the user’s role. For example, there is more API access for admin users.…