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 { myFetch } from './myFetch.js'; | |
async function withSuccess() { | |
const res = await myFetch({ url: 'https://dummyjson.com/todos' }) | |
if (res.message === 'Success') { | |
console.log('Yieee') | |
} else { | |
console.log(res.reason) | |
} |
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
// package.json | |
{ | |
"scripts": { | |
// standalone Jest | |
"test": "jest --maxWorkers=50%", | |
"test:watch": "jest --watch --maxWorkers=25%", | |
"test:ci": "jest --runInBand", | |
// or with Create React App | |
"test": "react-scripts test --watchAll=false --maxWorkers=50%", |
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
div{ | |
overflow-x: scroll; | |
-ms-overflow-style: none; /* IE and Edge */ | |
scrollbar-width: none; /* Firefox */ | |
&::-webkit-scrollbar { | |
display: none; | |
} | |
} | |
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 getBase64 = file => { | |
return new Promise((resolve, reject) => { | |
const reader = new FileReader(); | |
reader.onload = () => resolve(reader.result); | |
reader.onerror = error => reject(error); | |
reader.readAsDataURL(file); | |
}); | |
}; | |
async function onChangeFile(e) { |
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 accessibleLS = () => { | |
try { | |
localStorage.setItem('check', true); | |
localStorage.removeItem(tcheckest); | |
return true; | |
} catch (e) { | |
return false; | |
} | |
}; |
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
function cached(fn){ | |
// Create an object to store the results returned after each function execution. | |
const cache = Object.create(null); | |
// Returns the wrapped function | |
return function cachedFn (str) { | |
// If the cache is not hit, the function will be executed | |
if ( !cache[str] ) { | |
let result = fn(str); |
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
class A{ | |
constructor(){ | |
this.name= "manisha" | |
this.demo = this.demo.bind(this); | |
} | |
demo(){ | |
const surname = "basra"; | |
return `${this.name} ${surname}` | |
} | |
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
/* css */ | |
.header { | |
background: #453434; /* overrided */ | |
} | |
// JSX | |
<Div className="header sc-wS45d" /> | |
const Div = styled.div` | |
&&& { |
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"; | |
import ReactDOM from "react-dom"; | |
const useSubmit = submitFunction => { | |
const [loading, setLoading] = useState(false); | |
const [error, setError] = useState(null); | |
const handleSubmit = async () => { | |
try { | |
setLoading(true); |
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'; | |
import { | |
CardElement, | |
injectStripe, | |
StripeProvider, | |
CardNumberElement, | |
CardExpiryElement, | |
CardCVCElement, | |
Elements | |
} from 'react-stripe-elements'; |
NewerOlder