Skip to content

Instantly share code, notes, and snippets.

View sagar-gavhane's full-sized avatar
🏠
Working from home

Sagar sagar-gavhane

🏠
Working from home
View GitHub Profile
const FakeModal = ({ children, show }) => (
<Fragment>
<div className="modal" style={{ display: show ? 'block' : 'none' }}>
<div className="modal-content">
<span className="close">&times;</span>
<div className="clearfix" />
<div className="modal-body">{children}</div>
</div>
</div>
</Fragment>
@sagar-gavhane
sagar-gavhane / seqExecuteStates.jsx
Created November 24, 2018 11:42
sequentially execute states.
import React from "react";
import { render } from "react-dom";
import "./styles.scss";
class App extends React.Component {
constructor(props) {
super(props);
this.state = { counter: 1 };
}
const Joi = require("joi");
const nanoid = require("nanoid");
const value = {
documents: [
{
type: "PAN_CARD",
number: nanoid(10),
expire_date: "2018-11-16T18:46:19-0700",
proof_for: "PROOF_OF_IDENTITY",

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
@sagar-gavhane
sagar-gavhane / README-Template.md
Created November 13, 2018 05:01 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@sagar-gavhane
sagar-gavhane / vscode-user-settings.json
Created November 7, 2018 07:37
vscode user settings
{
"editor.fontFamily": "'Source Code Pro', Menlo, Monaco, 'Courier New', monospace",
"terminal.integrated.fontFamily": "'Source Code Pro', 'Inconsolata for Powerline', monospace",
"editor.fontSize": 16,
"editor.fontWeight": "500",
"editor.lineHeight": 24.65,
"editor.letterSpacing": 0.5,
"files.trimTrailingWhitespace": true,
"prettier.eslintIntegration": true,
"editor.cursorStyle": "line",
@sagar-gavhane
sagar-gavhane / PlaygroundComponent.jsx
Created November 7, 2018 07:21
React suspense demo example created by me
import React, { Suspense } from "react";
import { createCache, createResource } from "simple-cache-provider";
const cache = createCache();
const readText = createResource((text) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(text);
}, 1000);
});
@sagar-gavhane
sagar-gavhane / useElementResizer.jsx
Created November 7, 2018 06:00
Observe for element resize.
import React, { useState, useEffect, useRef, } from "react";
const useElementResizer = (ref) => {
const [contentRect, setContentRect] = useState(ref.current ? ref.current.getBoundingClientRect() : {});
useEffect(() => {
if (!ref.current) return;
const observer = new window.ResizeObserver(entries => setContentRect(entries[0].contentRect));
observer.observe(ref.current);
@sagar-gavhane
sagar-gavhane / ContainerComponent.jsx
Last active October 28, 2018 10:46
This code snippets is created during writing article on react component patterns.
import React, { Component, Fragment } from "react"
class CommentList extends Component {
constructor() {
super()
this.state = { comments: [] }
}
componentDidMount() {
fetch("https://jsonplaceholder.typicode.com/comments")
@sagar-gavhane
sagar-gavhane / asyncComponent.jsx
Created October 22, 2018 06:19
This code snippets is created during writting article on "Code splitting in React". article link is here => https://medium.com/@sgavhane70/code-splitting-in-react-f475a0da4c3e
// filename: asyncComponent.jsx
import React, { Component } from "react";
const asyncComponent = (getComponent) => {
// return AsyncComponent class component
return class AsyncComponent extends Component {
static Component = null;
state = {
Component: AsyncComponent.Component // first time similar to static Component = null
};