File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55This allows the given "source code" to be fully typed (TypeScript).
66
7+ ## Example
8+
9+ ** Input**
10+
11+ ``` tsx
12+ const YourComponent = () => {
13+ const foo = ' bar'
14+ return (
15+ <LiveProvider scope = { { foo }} data-your-attributes >
16+ <div >{ foo } </div >
17+ </LiveProvider >
18+ )
19+ }
20+ ```
21+
22+ ** Output**
23+
24+ ``` tsx
25+ const YourComponent = () => {
26+ const foo = ' bar'
27+ return (
28+ <LiveProvider scope = { { foo }} data-your-attributes >
29+ { ` <div>{foo}</div> ` }
30+ </LiveProvider >
31+ )
32+ }
33+ ```
34+
35+ When used with a render callback, it is transformed to use ReactLive's ` render ` (noInline).
36+
37+ ** Input**
38+
39+ ``` tsx
40+ const YourComponent = () => {
41+ const foo = ' bar'
42+ return (
43+ <LiveProvider scope = { { foo , styled }} >
44+ { () => {
45+ const StyledDiv = styled .div `
46+ color: red;
47+ `
48+ return <StyledDiv >{ foo } </StyledDiv >
49+ }}
50+ </LiveProvider >
51+ )
52+ }
53+ ```
54+
55+ ** Output**
56+
57+ ``` tsx
58+ const YourComponent = () => {
59+ const foo = ' bar'
60+ return (
61+ <LiveProvider scope = { { foo , styled }} noInline >
62+ { `
63+ const StyledDiv = styled.div\`
64+ color: red;
65+ \`
66+ render(<StyledDiv>{foo}</StyledDiv>)
67+ ` }
68+ </LiveProvider >
69+ )
70+ }
71+ ```
72+
773## How to use
874
975Install ` babel-plugin-react-live ` and add it to your Babel config.
@@ -25,4 +91,4 @@ Install `babel-plugin-react-live` and add it to your Babel config.
2591
2692## How it works
2793
28- It uses AST to transform related code to a string.
94+ It uses Babel AST to transform related code to a string.
You can’t perform that action at this time.
0 commit comments