Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react native callback function uses default state value

...
const [details, setDetails] = useState({})

const stateRef = useRef(details)
stateRef.current = details

const callbackFn = () => {
	const currentDetails = stateRef.current
}
 
PREVIOUS NEXT
Tagged: #react #native #callback #function #default #state
ADD COMMENT
Topic
Name
8+1 =