Syntax von "onClick" in React Aufgabe #691
Replies: 2 comments 2 replies
-
wenn man in einem onClick direkt die Funktion schreibt und etwas übergeben möchte (hier Count - 1) zum Beispiel muss man das als Arrow Function schreibt deswegen () => {setCount(count-1)} |
Beta Was this translation helpful? Give feedback.
-
In React muss man immer zwischen zwei Situationen unterscheiden, in denen sich der Code befinden kann:
Wenn man gerade JSX schreibt, z.B. <button onClick={ function(){...} } type='button'>
---------------- ---------------- --------------
| | |
JSX Javascript JSX Das was du dann als Wert bei onClick definierst ist eine () => setCount(count + 1) Zusammen ergibt das dann den Code den du gepostet hast. |
Beta Was this translation helpful? Give feedback.
-
Hallo zusammen,
ich sitze gerade an der Wiederholung einer React-Aufgabe und verstehe die Syntax hier nicht.
Welche Aufgabe?
REACT STATE 1 - Aufgabe Counter
mir geht es nur um folgenden Part:
Beta Was this translation helpful? Give feedback.
All reactions