What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-13 02:23:12
render props
//Render props are functions that are passed to props as values const User = (props) => { const [name, setName] = useState('John') //we pass values to prop-function as args return <div>{props.render(name)}</div> } //Then we can use thi... Add solution -
Javascript 2021-11-12 15:14:19
high level components react
import React, { useState } from 'react'; class WelcomeName extends React.Component { render() { return <h1>Hello, {this.props.name}</h1> } } function HighHookWelcome() { const [name ,setName] = useState("Default Name Here"... Add solution -
Javascript 2021-11-12 10:07:35
detect browser back button click react
import { useHistory } from 'react-router-dom' const [ locationKeys, setLocationKeys ] = useState([]) const history = useHistory() useEffect(() => { return history.listen(location => { if (history.action === 'PUSH') { setLocationKeys([... Add solution -
Javascript 2021-11-10 16:07:18
react enzyme simulate click sub component
// 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 -
CSS 2021-11-10 14:01:16
How to add object in an array using useState
import React, { useState } from 'react'; function App() { const [items, setItems] = useState([]); // handle click event of the button to add item const addMoreItem = () => { &nb... Add solution -
Other 2021-11-09 13:14:17
infinite-scroll react
import { useState } from "react"; import useInView from "react-cool-inview"; import axios from "axios"; const App = () => { const [todos, setTodos] = useState(["todo-1", "todo-2", "..."]); ... Add solution