What do you want to save?
Add Code snippet
New code examples
-
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 -
Javascript 2021-09-25 11:00:03
usePrevious
import { useState, useEffect, useRef } from "react"; // Usage function App() { // State value and setter for our example const [count, setCount] = useState(0); // Get the previous value (was passed into hook on last render) const prevC... Add solution -
Javascript 2021-09-24 15:36:02
react keep screen on
// Download the nosleep.js bundle // npm install nosleep.js // Import and declare NoSleep // REACT CODE STARTS HERE import React from 'react'; import NoSleep from 'nosleep.js'; var noSleep = new NoSleep(); const WakeButton = () => { return( <div&... Add solution -
Javascript 2021-09-24 11:40:02
how to convert react component to image
import { exportComponentAsJPEG, exportComponentAsPDF, exportComponentAsPNG } from 'react-component-export-image'; import React from 'react'; class ComponentToPrint extends React.Component { render() { return <div>Hello World</div>; } } e... Add solution -
Javascript 2021-09-22 12:30:02
passing argument to function handler functional compoent javascript react
function MyComponent(props) { function handleChange(event, data){ console.log(event.target.value); console.log(data) } return <button onClick={(event) => handleChange(event, 'Some Custom Value')} value='Foo'>Click</button> } Add solution -
Javascript 2021-09-20 09:42:02
react change state
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-09-17 14:09:01
two way binding react
import React, { useState } from “react”; import Child from “./Child”; function Parent(props) { const [text, setText] = useState(“Hello”); return ( <div> <h1>{text}</h1> <Child changeText={(text) =&g... Add solution
Best helpers
Ranking is empty