File tree Expand file tree Collapse file tree 1 file changed +48
-1
lines changed
Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ yarn add react-webcomponentify
1616
1717# Usage
1818
19+ ** Basic**
20+
1921``` js
2022import React from " react" ;
2123import { registerAsWebComponent } from " react-webcomponentify" ;
@@ -40,5 +42,50 @@ In HTML:
4042</html >
4143```
4244
45+ ** Advanced**
46+
47+ ``` js
48+ import React from " react" ;
49+ import { registerAsWebComponent } from " react-webcomponentify" ;
50+
51+ export const ButtonComponent = props => {
52+ return (
53+ < div>
54+ Hello < button onClick= {props .onClick }> {props .text }< / button>
55+ < / div>
56+ );
57+ };
58+
59+ registerAsWebComponent (ButtonComponent, " button-web" );
60+ ```
61+
62+ In HTML:
63+
64+ ``` html
65+ <!DOCTYPE html>
66+ <html >
67+ ....
68+ <body >
69+ <button-web text =" click me" id =" mybutton" />
70+ </body >
71+ ....
72+ <script >
73+ const myBtn = document .getElementById (" mybutton" );
74+ myBtn .setProps ({
75+ onClick : () => console .log (" btn was clicked" )
76+ });
77+ </script >
78+ </html >
79+ ```
80+
81+ Every custom component built using react-webcomponentify will have an instance method ` setProps `
82+
83+ ``` js
84+ element .setProps ({
85+ ... .
86+ /* set the props here that you want to send to react */
87+ ... .
88+ })
89+ ```
4390
44- # More examples and scenarios coming soon...
91+ # More detailed examples and scenarios coming soon...
You can’t perform that action at this time.
0 commit comments