What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-26 03:43:05
how to call a function in react with arguments onclick
import React from 'react'; const ExampleComponent = () => { function sayHello(name) { alert(`hello, ${name}`); } return ( <button onClick={() => sayHello('James')}>Greet</button> ); } export default ExampleComponent; Add solution -
Javascript 2021-10-24 00:24:05
pass setstate to child
//ChildExt component class ChildExt extends React.Component { render() { return (<div><button onClick={() => this.props.handleForUpdate('someNewVar')}>Push me</button></div> )} } //Parent component class Pare... 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-23 20:48:06
state creation and updation in class components reactjs interview questions
class Car extends React.Component { constructor(props) { super(props); this.state = { brand: "BMW", color: "Black" }; } changeColor() { this.setState(prevState => { return { color: "Red" }; ... Add solution -
Javascript 2021-10-19 11:05:08
apply back button to a react component
import { useHistory } from "react-router-dom"; export const Item = () => { let history = useHistory(); return ( <> <button onClick={() => history.goBack()}>Back</button> </> );... Add solution -
Javascript 2021-10-13 19:38:03
create tic tac toe game in react using jsx files
function Square(props) { return ( <button className="square" onClick={props.onClick}> {props.value} </button> ); } class Board extends React.Component { renderSquare(i) { return ( <Square val... Add solution -
Javascript 2021-10-12 00:25:07
react spinkit
// ##### Installation ##### // npm install --save react-spinners // ##### Installation ##### // https://www.davidhu.io/react-spinners // ##### Example ##### import { useState } from "react"; import { css } from "@emotion/react"; ... 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
Best helpers
Ranking is empty