Pass Context between Siblings Using Context in React

export const NumberContext = React.createContext(); function App() { const [foo, changeFoo] = useState('foo') return ( <NumberContext.Provider value={{ foo, changeFoo }}> <TheButton /> <Display /> </NumberContext.Provider> ); } function TheButton() { const { changeFoo } = useContext(NumberContext) return ( <button onClick={() => changeFoo('bar')}>Click me</button> ); } function Display() { const context Read more…

ES6 Promise

1. What is Promise Promise is a solution for asynchronous programming. It is actually a constructor with its own methods all, reject and resolve, and prototype methods such as then and catch. The Promise object has the following two features: The Promise object represents an asynchronous operation with three states: Read more…

Catalogue