What do you want to save?
Add Code snippet
New code examples
-
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-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-16 18:41:05
why we use hooks in react
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 doc... Add solution -
Javascript 2021-09-10 08:02:02
reusable star rating component in react
import { Box, createStyles, Grid, Input, makeStyles, Theme, FormHelperText } from '@material-ui/core'; import React from 'react'; import StarIcon from '@material-ui/icons/Star'; import clsx from 'clsx'; //-----------------------------------... Add solution -
Javascript 2021-09-07 01:48:02
keyboard event height react native
import { useEffect, useState } from 'react'; import { Keyboard, KeyboardEvent } from 'react-native'; export const useKeyboard = (): [number] => { const [keyboardHeight, setKeyboardHeight] = useState(0); function onKeyboardDidShow(e: KeyboardEvent... Add solution -
Javascript 2021-09-03 00:30:01
react ezyme simulate click
// App.js function App() { const [count, setCount] = React.useState(0) const onClick = () => { setCount((prevState) => prevState + 1) } return ( <div> <button onClick={onClick}>{count}</button> </div&... Add solution