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 reactjs.org.
will work on this
from reactjs.org.
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 reactjs.org.
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 reactjs.org.
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 reactjs.org.
@Frazer added to the FAQ version of this topic: b2ef5ff
from reactjs.org.
Closed by #81 I think
from reactjs.org.
@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 reactjs.org.
from reactjs.org.
how many times do we need to have this debate in react.
from reactjs.org.
Related Issues (20)
- [Typo]: Missing Blank Line Between Import Statements and Code Block in Sample Code
- Close
- [Suggestion]: use toSorted and toReversed for the examples in Updating Array in State Page HOT 2
- The Link do not work HOT 2
- Mosibl policy HOT 2
- Not Found This page doesnโt exist. HOT 1
- [Bug]: `analyze` workflow fails because of deprecated version of `actions/upload-artifact` HOT 3
- https://react.dev/docs/lists-and-keys.html#keys is 404 not found HOT 1
- ReactJS
- [Bug]: React 16 docs redirect to React 17 with no explanation HOT 1
- [Suggestion]: The official way to build a simple static generated website (SSG) without Next.js
- `rss.js` page error for the author, date and description HOT 2
- Always Fail PR at analyze job. HOT 1
- โReact Server Componentโ link is not available in zh-hans.react.dev HOT 1
- Extracting Emotion Styles for a Specific Component Using Ref
- [Bug]: Example given in "Handling return values in forms" section for "use-server" docs fails to compile
- page missing from docs
- [Typo]: change info about startTransition, now can be used with async func
- [Bug]: State bug breaking search and eventually freezing up
- [Typo]: Documentation Incorrectly States getVisibleTodos() Re-runs on Input Change HOT 1
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 reactjs.org.