Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
React Hooks vs. Inline
(version: 0)
Comparing performance of:
Inline vs Hooks
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<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>
Script Preparation code:
function ComponentWithInlineFunction() { const clickMe = evt => evt.preventDefault(); return React.createElement('button', {onClick: clickMe}, 'Click me!'); } function ComponentWithUseCallback() { const clickMe = React.useCallback(evt => evt.preventDefault(), []); return React.createElement('button', {onClick: clickMe}, 'Click me!'); }
Tests:
Inline
ReactDOM.render(React.createElement(ComponentWithInlineFunction), document.getElementById('root'))
Hooks
ReactDOM.render(React.createElement(ComponentWithUseCallback), document.getElementById('root'))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Inline
Hooks
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
10 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser/OS:
Chrome 137 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Inline
1084424.6 Ops/sec
Hooks
1715250.4 Ops/sec
Related benchmarks:
React Hooks vs. Inline (React 16.14.0)
React useCallback hook vs inline function
React useCallback hook vs inline function with state react 17
React useCallback vs inline function vs inline handler
Comments
Confirm delete:
Do you really want to delete benchmark?