Pawan Kumar
Pawan Kumar
App.tsx ```tsx App.tsx import React, { useState, useRef } from "react"; import { Stepper, StepperRef } from "./Stepper"; const App = () => { const steps = ["Login", "Shipping", "Payment",...
## Info ```yaml difficulty: medium title: clearAllTimeout type: question template: javascript tags: javascript, timers ``` ## Question In JavaScript, `clearTimeout` is used to cancel a **single** timeout. Your task is...
useReducer.js ```js useReducer.js import { useState } from "react"; export function useReducer(reducer, initialState) { const [state, setState] = useState(initialState); const dispatch = (action) => { setState(() => reducer(state, action)); };...
App.jsx ```jsx App.jsx import { useState, useEffect } from "react"; const PAGE_SIZE = 5; export default function App() { const [page, setPage] = useState(1); const [storyIDs, setStoryIDs] = useState([]); const...
App.jsx ```jsx App.jsx import { useEffect, useState } from 'react'; const Input = ({ onChange, label, placeholder, id }) => { useEffect(() => { console.log(`Input mounted`); }, []); return (...
App.jsx ```jsx App.jsx import { useState } from 'react'; const ComponentWithState = () => { const [isActive, setIsActive] = useState(false); return ( setIsActive(!isActive)}>click to highlight ); }; export default function...
App.jsx ```jsx App.jsx import { useState } from "react"; export default function App() { const [isCompany, setIsCompany] = useState(false); return ( e.target.checked ? setIsCompany(true) : setIsCompany(false) } /> Is Comapny?...
App.jsx ```jsx App.jsx import { useState } from "react"; export default function App() { const [isCompany, setIsCompany] = useState(false); return ( e.target.checked ? setIsCompany(true) : setIsCompany(false) } /> Is Comapny?...
Is there a way to use fakeTimers in sandpack's tests component? Currently I am forced to use realTimers. It works but it takes a long time to see the tests...