This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { | |
Dispatch, | |
SetStateAction, | |
useState, | |
useRef, | |
useEffect, | |
} from 'react'; | |
export default function useMountedState<S>( | |
initialState: S | (() => S), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React , { useState } from 'react' | |
function Clipboard { | |
const [copySuccess , setCopySuccess] = useState(false) | |
const [textArea, setTextArea] = useState() | |
function copyCodeToClipboard () { | |
const el = textArea | |
el.select() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
Method 1 | |
``` | |
let fibonacci = function(n){ | |
if(n == 1) { | |
return [0,1] | |
} | |
else { | |
let s = fibonacci(n-1) | |
console.log(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const redux = require('redux') | |
const createStore = redux.createStore; | |
const initialState = { | |
counter : 0 | |
} | |
// reducer | |
const rootReducer = (state = initialState,action) => { | |
if (action.type === 'INC_COUNTER') { |