initialization of state variables when component renders & custom hooks
I have a component Body.jsx
, it contained logic of fetching data from an API and filtering as well.
I tried to create a custom hook useResData
which separates out logic of fetching data as shown-
React – my calendar is opening twice on click of cancel button
so basically if in my page there are two date picker, first datepicker works fine on click of datepicker-cancel button but when i open second date picker and hit cancel then datepicker re-renderes. can anyone please help me with the same.
what is the best way to ignore eslintreact-hooks/exhaustive-deps
I have a useEffect hook look like this:
why can i do early return when its not allowed in react?
import React,{useState} from ‘react’; function Car() { const [count, setCount] = useState(0); return <h2>a Car!</h2>; } export function App(props) { const [count, setCount] = useState(0); if(count===3) return ; let b=<Car/> return ( <div className=’App’> <Car/> <button onClick={() => setCount(count + 1)}> Click me {count} </button> </div> ); } when rendering app usestate at top level […]