Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Shyam Ghanshyam-K-Dobariya

🎯
Focusing
Block or report user

Report or block Ghanshyam-K-Dobariya

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Ghanshyam-K-Dobariya
Ghanshyam-K-Dobariya / This_In_React_Component.md
Last active Aug 20, 2019
Value of this inside react component method
View This_In_React_Component.md

In a JavaScript method, the value of this has nothing to do with the class on which it was defined. Instead, it depends on the object that it was called upon.

import React from "react";
import ReactDOM from "react-dom";

class App extends React.Component {
  render() {
    var { handleClick } = this;
@Ghanshyam-K-Dobariya
Ghanshyam-K-Dobariya / FormValidation.html
Created Aug 20, 2019
Basic form validation using vanila js
View FormValidation.html
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
<script>
function isValidEmailId(emailId) {
var exp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
return exp.test(emailId)
}
View JS_Getters_Setters.md

Ever wondered why setting array.length = 0 makes an array empty or array.length = 'some string' throws exception ? Code example.

screen shot 2018-09-14 at 10 16 50 
am

So now you have curiosity to know what happens in the background when command array.length = 0 takes place ?

Let's start this journey with below requirement.

View Log_inside_life_cycle_method_of_a_user_defined_component.md

Create a higher order function that accepts a react component. Do logs when life cycle methods (componentWillReceiveProps or render) are called

F1.js

export function hocF (Component) {
  const cwp = Component.prototype.componentWillReceiveProps;
  Component.prototype.componentWillReceiveProps = function(...args) {
    console.log('in Component will receive props....')
    cwp.call(this, ...args)
  }
You can’t perform that action at this time.