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: docs/api.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,32 +4,32 @@
4
4
5
5
-`ReactComponent` - A React component that you want to
6
6
convert to a Web Component.
7
-
-`React` - A version of React (or [preact-compat](https://preactjs.com/guide/v10/switching-to-preact)) the
8
-
component works with.
9
-
-`ReactDOM` - A version of ReactDOM (or preact-compat) that the component works with.
10
-
-`options` - An optional set of parameters.
7
+
-`options` - An set of parameters.
11
8
12
9
-`options.shadow` - Use shadow DOM rather than light DOM.
13
10
-`options.props` - Array of camelCasedProps to watch as String values or { [camelCasedProps]: String | Number | Boolean | Function | Object | Array | "ref" }
14
11
15
12
- When specifying Array or Object as the type, the string passed into the attribute must pass `JSON.parse()` requirements.
16
13
- When specifying Boolean as the type, "true", "1", "yes", "TRUE", and "t" are mapped to `true`. All strings NOT begining with t, T, 1, y, or Y will be `false`.
17
14
- When specifying Function as the type, the string passed into the attribute must be the name of a function on `window` (or `global`). The `this` context of the function will be the instance of the WebComponent / HTMLElement when called.
15
+
- If PropTypes are defined on the React component, the `options.props` will be ignored and the PropTypes will be used instead.
16
+
However, we strongly recommend using `options.props` instead of PropTypes as it is usually not a good idea to use PropTypes in production.
17
+
- If `options.props` is an array of string (prop names), the type of those props will be `String`.
18
18
19
19
A new class inheriting from `HTMLElement` is
20
-
returned. This class can be directly passed to `customElements.define` as follows:
20
+
returned. This class is of type CustomElementConstructor can be directly passed to `customElements.define` as follows:
Components can also be implemented using [shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM) with either `open` or `closed` mode.
Then `React.createRef()` will automatically happen behind the scenes then attach the reference to the webcomponent instance if it has the corresponding attribute.
0 commit comments