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
If `options.props` is an object, the keys are the camelCased React props and the values are any one of the following built in javascript types, or the string "ref":
110
+
If `options.props` is an object, the keys are the camelCased React props and the values are any one of the following built in javascript types.
111
+
This is the recommended way of passing props to r2wc.
Then `React.createRef()` will automatically happen behind the scenes then attach the reference to the webcomponent instance if it has the corresponding attribute.
console.log(el.ref.current.exposedToParentByRef) // logs true using either the functional or class example above
257
-
console.log(el.ref.currentinstanceof ComRef) // logs true only if you used the class ComRef component example
258
-
259
-
consth1=el.querySelector("h1")
260
-
261
-
console.log(el.h1Ref.current=== h1) // logs true
262
-
}, 0)
263
-
```
264
-
265
-
#### Specifing a callback function for ref props
266
-
267
-
If your `"ref"` type webcomponent attribute specifies a value, the value will be the name of a global function (like the `Function` prop type above) and be used as a callback reference, recieving the dom element the React component attaches it to as a parameter.
268
-
269
-
```js
270
-
window.globalRefFn=function (el) {
271
-
if (!el) {
272
-
// if the component rerenders the referenced element, the callback may run with el = null
0 commit comments