Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Test: React useCallback vs notUseCallback
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser:
Chrome 137
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Without useCallback
923098.1 Ops/sec
With useCallback
1521279.4 Ops/sec
HTML Preparation code:
<!doctype html> <html> <head> <title>This is the title of the webpage!</title> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.13.1/umd/react-dom.production.min.js"></script> <div id="root"></div> </body> </html>
Script Preparation code:
function ComponentWithOutUseCallback() { const testFunction = (evt) => evt.preventDefault() return React.createElement('button', {onClick: testFunction}, 'Test click'); } function ComponentWithUseCallback() { const testFunction = React.useCallback(evt => evt.preventDefault(), []); return React.createElement('button', {onClick: testFunction}, 'Test click'); }
Tests:
Without useCallback
ReactDOM.render(React.createElement(ComponentWithOutUseCallback), document.getElementById('root'))
With useCallback
ReactDOM.render(React.createElement(ComponentWithUseCallback), document.getElementById('root'))