Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to count react renders

// play with this on codesandbox: https://codesandbox.io/s/react-codesandbox-g9mt5

import * as React from 'react'
import ReactDOM from 'react-dom'

function Logger(props) {
  console.log(`${props.label} rendered`)
  return null // what is returned here is irrelevant...
}

function Counter() {
  const [count, setCount] = React.useState(0)
  const increment = () => setCount(c => c + 1)
  return (
    <div>
      <button onClick={increment}>The count is {count}</button>
      <Logger label="counter" />
    </div>
  )
}

ReactDOM.render(<Counter />, document.getElementById('root'))
Comment

PREVIOUS NEXT
Code Example
Javascript :: check for string anagram javascript 
Javascript :: angular 6 key value pair getvalue example 
Javascript :: what is json 
Javascript :: print all the subarrays of an array 
Javascript :: Javascript How to push a key value pair into a nested object array 
Javascript :: installing react router dom 
Javascript :: js object keys 
Javascript :: reload page after form submit javascript 
Javascript :: js json parse 
Javascript :: new date null javascript 
Javascript :: scroll down or up event listener 
Javascript :: js addeventlistener foreach 
Javascript :: regex not something 
Javascript :: vuejs router params 
Javascript :: js mouse move activate 
Javascript :: js add begin array 
Javascript :: catch javascript 
Javascript :: remove comma from end of string javascript 
Javascript :: vue loop 
Javascript :: javascript check if array 
Javascript :: clean collection mongoose 
Javascript :: how to change css variable in javascript 
Javascript :: this.handler.handle is not a function 
Javascript :: next.js index page 
Javascript :: new blob javascript 
Javascript :: usehistory hook 
Javascript :: node js sleep between axios 
Javascript :: node json db 
Javascript :: vue 3 create component 
Javascript :: how to check if browser is firefox in javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =