Comments (10)
@Frazer The overhead of creating a function during render is rarely a performance problem. We do it all the time to add event handlers, map arrays, etc. The new hooks API also makes heavy use of this pattern for hooks like useEffect
and useMemo
(which require creating a function every render, even if it's not called every render).
When it can be a problem is when it breaks memoization and causes a performance sensitive subtree of your application to re-render when it would otherwise not have re-rendered. This is something the DevTools Profiler UI can help you identify and fix though.
from react.dev.
will work on this
from react.dev.
This issue is all yours! π
I've added an "in-progress" label so that others will know not to start work on the issue. If you change your mind about the issue, no worries! Just let me know so that I can remove the label and free it up for someone else to claim.
Cheers!
from react.dev.
This topic was also been suggested for the FAQ in #29, so I included some comments in PR #43 (diff).
It might be a good idea to merge the docs on this subject, or link from one to the other.
from react.dev.
I think @hedgerh suggestion should also be included.
<button name='23' onClick={this.deleteRow}>Delete Row</button>
deleteRow (e) {
// do some action to (e.target.name)
}
from react.dev.
@Frazer added to the FAQ version of this topic: b2ef5ff
from react.dev.
Closed by #81 I think
from react.dev.
@StokeMasterJack @bvaughn There is also a third way through currying (see How to pass variables to a function reference?, thx @esthercuan) π
deleteRow = id => event => {
event.preventDefault();
console.log('row ${id} deleted');
}
<button onClick={this.deleteRow(23)}>Delete Row</button>
from react.dev.
from react.dev.
how many times do we need to have this debate in react.
from react.dev.
Related Issues (20)
- [Mistake]: One of the examples in the docs is performing side effect in render? HOT 2
- [Bug]: Can not access the react.dev website HOT 11
- [Bug]: Issue with Sandpacks HOT 7
- Add language switcher to the design in react.dev
- [Suggestion]: Add example for retry with the `use` hook and an error boundary
- [Suggestion]: How to use local language search on a translation website
- [Suggestion]: Clarification on react.cache Usage in Server Requests
- [Typo]: Possible incorrect info HOT 1
- [Suggestion]: Add a new page for how to communicate between components. HOT 4
- [Suggestion]: "falsy" values not in the new documentation HOT 2
- [Bug]: sidepanel is blocking main content HOT 3
- [Suggestion]: Change the error message "Objects are not valid as a React child (found: object with keys {aaa, bbb}). If you meant to render a collection of children, use an array instead.
- [Mistake]: getVisibleTodos() does not re-run (and does not print any logs) when you type into the input to begin with! HOT 2
- δΈζζζ‘£ε·²η»uiεε½’δΊ HOT 1
- Class domain layer HOT 5
- Renren_kim86
- te.react.dev Maintainer's Issue HOT 3
- [Bug]: Search functionality not working correctly on react.dev in Safari on iOS real device (iPhone 12 Pro) HOT 2
- [Bug]: Search functionality not working correctly on react.dev in Safari on iOS real device (iPhone 12 Pro) HOT 3
- [Typo]: There is a syntax mistake on react docs GetStarted/Installation/Using Typescript HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react.dev.