You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/components/index.md
+49-9Lines changed: 49 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -188,8 +188,21 @@ Non-string JavaScript values passed to custom elements will be serialized by def
188
188
189
189
React will, however, recognize an custom element's property as one that it may pass arbitrary values to if the property name shows up on the class during construction:
@@ -203,12 +216,33 @@ class MyElement extends HTMLElement {
203
216
}
204
217
```
205
218
219
+
```js src/App.js
220
+
exportfunctionApp() {
221
+
return<my-element value={[1,2,3]}></my-element>
222
+
}
223
+
```
224
+
225
+
</Sandpack>
226
+
206
227
#### Listening for events on custom elements {/*custom-element-events*/}
207
228
208
-
A common pattern when using custom elements is that they may dispatch [`CustomEvent`s](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) rather than accept a function to call when an event occur:
229
+
A common pattern when using custom elements is that they may dispatch [`CustomEvent`s](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) rather than accept a function to call when an event occur. You can listen for these events using an `on` prefix when binding to the event via JSX.
Events are case-sensative and support dashes (`-`). Preserve the casing of the event and include all dashes when listening for custom element's events:
0 commit comments