Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react using button props child

function Button(props){


  return (
  <button onClick={props.onClickFunction}>
     +1
      </button>);
}
function Display(props){
  return(
  <div>{props.message}</div>);
}
function App(){
    const [counter, setCounter] = useState(0);
   const handleClick = () => setCounter(counter+1);
  return (
      <>
      <Button onClickFunction= {handleClick}/>
      <Display message={counter}/>
      </> );
}
ReactDOM.render(
<App />,
  document.getElementById('mountNode')

  );
Comment

PREVIOUS NEXT
Code Example
Javascript :: js code to accept all linkedin requests 
Javascript :: how to push array 
Javascript :: js convert a string into a number 
Javascript :: preview multiple image before upload 
Javascript :: color picker in react js 
Javascript :: window.open 
Javascript :: copy js object 
Javascript :: switch case statement in javascript 
Javascript :: axios display nested json console.log 
Javascript :: set radgrid datasource clientside 
Javascript :: create new record mongoose 
Javascript :: apar chinmoy phy js code 
Javascript :: react native swipe screen 
Javascript :: crud in node 
Javascript :: angular javascript 
Javascript :: Is there an “exists” function for jQuery 
Javascript :: getx oninit 
Javascript :: js if the reverse of a number is better than the original num 
Javascript :: reverse method in javascript 
Javascript :: fake delay in fetch 
Javascript :: delate char betwen index js 
Javascript :: beanstalk nodejs default port 
Javascript :: fcm node 
Javascript :: image loading in Compose display image 
Javascript :: compare string length javascript 
Javascript :: vscode new file shortcut 
Javascript :: check if localstorage is undefined 
Javascript :: Material-ui clock icon 
Javascript :: javascript switch syntax 
Javascript :: onselect in zebra datepicker 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =