Skip to content

Instantly share code, notes, and snippets.

View memon07's full-sized avatar
🎮
On a Journey

Memon Shoyeb memon07

🎮
On a Journey
View GitHub Profile
@memon07
memon07 / useMountedState.js
Created June 15, 2020 14:56
Custom hook to prevent memory leakage
import React, {
Dispatch,
SetStateAction,
useState,
useRef,
useEffect,
} from 'react';
export default function useMountedState<S>(
initialState: S | (() => S),
@memon07
memon07 / clipboard.js
Created December 28, 2019 10:44
Clipboard Copy in react js (without any npm)
import React , { useState } from 'react'
function Clipboard {
const [copySuccess , setCopySuccess] = useState(false)
const [textArea, setTextArea] = useState()
function copyCodeToClipboard () {
const el = textArea
el.select()
@memon07
memon07 / google-map.js
Created May 24, 2019 05:14
Google Map in React without any external library
import React , { Component } from 'react'
class Map extends Component {
componentDidMount () {
this.renderMap()
}
renderMap = () => {
loadScript('https://maps.googleapis.com/maps/api/js?key=APIKEY&callback=initMap')
```
Method 1
```
let fibonacci = function(n){
if(n == 1) {
return [0,1]
}
else {
let s = fibonacci(n-1)
console.log(s)
@memon07
memon07 / Redux-basic.js
Created April 29, 2019 08:22
Simple redux working
const redux = require('redux')
const createStore = redux.createStore;
const initialState = {
counter : 0
}
// reducer
const rootReducer = (state = initialState,action) => {
if (action.type === 'INC_COUNTER') {