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 * as React from "react"; | |
/** | |
* A helper to create a Context and Provider with no upfront default value, and | |
* without having to check for undefined all the time. | |
*/ | |
function createCtx<A extends {} | null>() { | |
const ctx = React.createContext<A | undefined>(undefined); | |
function useCtx() { | |
const c = React.useContext(ctx); |
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 tokens = ['USDC', 'USDT', 'ETH']; | |
const contracts = [{contract:"#CAS#", tokens: ["BTC"]},{contract: "FSA@#", tokens:["ETH","USF"]},{contract: "8%SD8", tokens:["ETH" ]}] | |
const intersection = contracts.filter(contract => tokens.some(token => { | |
return contract.tokens.includes(token) | |
})) |
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
{ | |
devtool: 'source-map' | |
} |
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
// just add the sideEffects key inside your package.json file | |
{ | |
"sideEffects": [ | |
"./src/polyfill.js" | |
], | |
} |
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 { divide, subtract } from "./mathUtils"; | |
divide(1, 2); |
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
//in that case all the build files were served by build/static adapt to your needs | |
"scripts": { | |
"analyze": "webpack-bundle-analyzer 'build/static/js/*.js'", | |
... | |
} |
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 path = require('path'); | |
module.exports = { | |
entry: { | |
vendor: './vendor.js', | |
main: './index.js' | |
}, | |
output: { | |
path: path.join(__dirname, 'build'), | |
filename: '[name].[hash].js' |
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
export const fetchSmallDevicesData = async ( | |
resolution, | |
filters, | |
pages | |
) => { | |
const { data } = await axios.get( | |
`${URL}?${buildSmartDevicesParameters( | |
resolutions, | |
filters, | |
pages |
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 { useState, useEffect } from 'react'; | |
export function useFetch( | |
doFetch, | |
dependencies | |
) { | |
const [loading, setLoading] = useState(false); | |
const [data, setData] = useState(); | |
useEffect(() => { |
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 state = useContext(MessagesContext); | |
const [textValue, setTextValue] = useState(""); | |
const [isEmojiEnabled, setIsEmojiEnabled] = useState(false); | |
const toggleEmoji = () => setIsEmojiEnabled(!isEmojiEnabled); | |
const myStateRef = useRef(textValue); | |
const setMyState = (data: any) => { | |
myStateRef.current = data; |
NewerOlder