Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react with two components render

function Button() {
  const [counter, setCounter] = useState(2);
  const handleClick = ()=> setCounter(counter*2);
  return (
  <button onClick={handleClick}>
      {counter}
      </button>
    );
}
function Display(){
  return(
  <div>....</div>);
}
ReactDOM.render(
<div>
  <Button />
  <Display />
</div>,
  document.getElementById('mountNode')

);
Source by jscomplete.com #
 
PREVIOUS NEXT
Tagged: #react #components #render
ADD COMMENT
Topic
Name
1+3 =