Tuesday, June 16, 2020
Saturday, May 16, 2020
React Hooks Testing
I am adding the reference to this blog, https://medium.com/javascript-in-plain-english/testing-react-hooks-be74ec3fc0c4, only because the author used a gif of 'Indiana Jones' which is a cool way of explaining a mock function. I haven't read the article yet.
More to come here...
More to come here...
Sunday, May 3, 2020
React Redux Example
Basics:
- Redux provides means to create an empty store where application state can be manufactured.
- You tell the store what to create as the application state, how to update the application state thru reducer.
- Reading from the application state in application is straight forward.
- Updating the application state is by triggering the update logic in the store by dispatching the actions.
- NOTE: When you update a state, you don’t update the state but rather create a new state out of old state.
- react-redux provides couple of additional facilities, Provider and connect.
- Provider to provide the store to the root component.
- Connect passes state, dispatch actions to child component.
Example:
- npx create-react-app reduxexample
- cd reduxexample
- npm install redux
- npm install react-redux
- Remove all files under src folder and public folder
- Create index.html under public folder
- Create rest of the files under src folder
- npm start
index.html
index.js
reducer.js
dispatcher.js
kitchen.jsx
Menu.jsx
App.jsx
Wednesday, April 22, 2020
Rest API with NodeJS and Loopback or Fastify or just nodejs
Totally surprised when I saw the search results for the key words: 'node and rest api in 5 minutes'
Building Rest API with LoopBack: Mind blowing, read this article: https://www.freecodecamp.org/news/build-restful-api-with-authentication-under-5-minutes-using-loopback-by-expressjs-no-programming-31231b8472ca/
About Loopback:
https://auth0.com/blog/developing-restful-apis-with-loopback/
https://www.npmjs.com/package/loopback
https://loopback.io/doc/en/lb4/express-with-lb4-rest-tutorial.html
Using Fastify:
https://medium.com/zero-equals-false/build-rest-apis-in-5-minutes-with-node-js-and-fastify-5c72b67e2cd3
Just nodeJS:
https://www.codementor.io/@olatundegaruba/nodejs-restful-apis-in-10-minutes-q0sgsfhbd
Building Rest API with LoopBack: Mind blowing, read this article: https://www.freecodecamp.org/news/build-restful-api-with-authentication-under-5-minutes-using-loopback-by-expressjs-no-programming-31231b8472ca/
About Loopback:
https://auth0.com/blog/developing-restful-apis-with-loopback/
https://www.npmjs.com/package/loopback
https://loopback.io/doc/en/lb4/express-with-lb4-rest-tutorial.html
Using Fastify:
https://medium.com/zero-equals-false/build-rest-apis-in-5-minutes-with-node-js-and-fastify-5c72b67e2cd3
Just nodeJS:
https://www.codementor.io/@olatundegaruba/nodejs-restful-apis-in-10-minutes-q0sgsfhbd
Saturday, April 18, 2020
ES6 Super quick reference
Arrow functions:
// ES5
function sayHello (name) {
return 'Hello ' + name
}
// ES6
const sayHello = (name) => 'Hello ' + name
console.log(sayHello('Ramesh'))
Variables:
var firstName = 'Ramesh'; // ES5 let firstName = 'Ramesh' // ES6 - have block scope const firstName = 'Ramesh' // ES6 - as it says, it's a constant
Template Strings:
let strWelcome = 'Welcome'
// use the backticks to combine strings with variableslet templateString = `${strWelcome} Ramesh` console.log(templateString)
async await:
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_awaitDestructuring:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignmentShorthand objects
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializerFunction arguments
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/argumentsExpand arrays
https://www.smashingmagazine.com/2016/07/how-to-use-arguments-and-parameters-in-ecmascript-6/let myArray = [1,2,3] Math.max(...myArray)
Classes
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/class
Subscribe to:
Posts (Atom)






