What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-27 19:26:08
automated counter with react hooks
import React, { useState } from 'react'; function Example() { // Declaración de una variable de estado que llamaremos "count" const [count, setCount] = useState(0); return ( <div> <p>You clicked {count} times&l... Add solution -
Javascript 2021-10-27 06:42:13
reawct uweeffect
import React, { useState, useEffect } from 'react'; function Example() { const [count, setCount] = useState(0); // Similar to componentDidMount and componentDidUpdate: useEffect(() => { // Update the document title using the browser API ... Add solution -
Javascript 2021-10-24 00:23:06
setstate in react
import React, { useState } from 'react'; function Example() { // Declare a new state variable, which we'll call "count" const [count, setCount] = useState(0); return ( <div> <p>You clicked {count} times</p> ... Add solution -
Javascript 2021-10-22 04:09:11
How to use `setState` callback on react hooks
//You need to use useEffect hook to achieve this. const [counter, setCounter] = useState(0); const doSomething = () => { setCounter(123); } useEffect(() => { console.log('Do something after counter has changed', counter); }, [counter]); Add solution -
Other 2021-10-19 19:51:09
how to get elevation with google elevation api
const [currentLatitude, setCurrentLatitude] = useState(0); const [currentLongitude, setCurrentLongitude] = useState(0); const [currentElevation, setCurrentElevation] = useState(0); useEffect( async () => { try { const res = await fetch(`ht... Add solution -
Javascript 2021-10-14 23:22:06
useeffect componentdidmount
import React, { useState, useEffect } from 'react'; function Example() { const [count, setCount] = useState(0); // Similar to componentDidMount and componentDidUpdate: useEffect(() => { // Update the document title using the browser AP... Add solution -
Javascript 2021-10-10 02:18:02
react hook usestate
import React, { useState } from 'react'; function Example() { // Declare a new state variable, which we'll call "count" const [count, setCount] = useState(0); return ( <div> <p>You clicked {count} times</p> ... Add solution -
Javascript 2021-10-02 13:34:05
useState hook example
import React, { useState } from 'react'; function Example() { // Declare a new state variable, which we'll call "count" const [count, setCount] = useState(0); return ( <div> <p>You clicked {count} times</p> ... Add solution