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
@@ -59,23 +54,18 @@ In the above case, the web-greeting custom element is not making use of the `nam
59
54
60
55
## Working with Attributes
61
56
62
-
By default, custom elements created by `reactToWebComponent` only
63
-
pass properties to the underlying React component. To make attributes
64
-
work, you must specify your component's properties with
65
-
[PropTypes](https://reactjs.org/docs/typechecking-with-proptypes.html) as follows:
57
+
By default, custom elements created by `reactToWebComponent` only pass properties to the underlying React component. To make attributes work, you must specify your component's props.
66
58
67
59
```js
68
-
importReactfrom"react"
69
-
importPropTypesfrom"prop-types"
70
-
import*asReactDOMfrom"react-dom/client"
71
-
72
60
constGreeting= ({ name }) => {
73
-
return<h1>Hello, {name}</h1>
61
+
return<h1>Hello, {name}!</h1>
74
62
}
75
63
76
-
Greeting.propTypes= {
77
-
name:PropTypes.string.isRequired,
78
-
}
64
+
constWebGreeting=reactToWebComponent(Greeting, {
65
+
props: {
66
+
name:"string",
67
+
},
68
+
})
79
69
```
80
70
81
71
Now `reactToWebComponent` will know to look for `name` attributes
0 commit comments