|
20 | 20 | <script type="text/babel"> |
21 | 21 | "use strict"; |
22 | 22 |
|
23 | | - function Embeddable({ |
24 | | - token, |
25 | | - onComponentsLoad, |
26 | | - variables, |
27 | | - onVariablesChange, |
28 | | - onEmbeddableError, |
29 | | - }) { |
| 23 | + function Embeddable({token, onComponentsLoad, variables, onVariablesChange, onEmbeddableError}) { |
30 | 24 | const ref = React.useRef(null); |
31 | 25 | function handleVariableChange(e) { |
32 | | - if (onVariablesChange) { |
| 26 | + if(onVariablesChange) { |
33 | 27 | onVariablesChange( |
34 | 28 | Object.fromEntries( |
35 | | - e.detail.map((c) => [c.variableName, c.newValue]), |
36 | | - ), |
37 | | - ); |
| 29 | + e.detail.map(c => [c.variableName, c.newValue]) |
| 30 | + ) |
| 31 | + ) |
38 | 32 | } |
39 | 33 | } |
40 | | - |
41 | 34 | function handleEmbeddableError(e) { |
42 | 35 | onEmbeddableError(e.detail); |
43 | 36 | } |
44 | | - |
45 | 37 | React.useEffect(() => { |
46 | | - ref.current.addEventListener("variablesChange", handleVariableChange); |
47 | | - ref.current.addEventListener("componentsLoad", onComponentsLoad); |
48 | | - ref.current.addEventListener( |
49 | | - "embeddableError", |
50 | | - handleEmbeddableError, |
51 | | - handleEmbeddableError, |
52 | | - ); |
| 38 | + ref.current.addEventListener('variablesChange', handleVariableChange); |
| 39 | + ref.current.addEventListener('componentsLoad', onComponentsLoad); |
| 40 | + ref.current.addEventListener("embeddableError",handleEmbeddableError); |
53 | 41 | return () => { |
54 | | - ref.current.removeEventListener("componentsLoad", onComponentsLoad); |
55 | | - ref.current.removeEventListener( |
56 | | - "variablesChange", |
57 | | - handleVariableChange, |
58 | | - ); |
59 | | - ref.current.removeEventListener( |
60 | | - "embeddableError", |
61 | | - handleEmbeddableError, |
62 | | - ); |
| 42 | + ref.current.removeEventListener('componentsLoad', onComponentsLoad); |
| 43 | + ref.current.removeEventListener('variablesChange', handleVariableChange); |
| 44 | + ref.current.removeEventListener("embeddableError",handleEmbeddableError); |
63 | 45 | }; |
64 | 46 | }, []); |
65 | | - return React.createElement("em-beddable", { |
66 | | - ref, |
67 | | - token, |
68 | | - variables: JSON.stringify(variables), |
| 47 | + return React.createElement('em-beddable', { |
| 48 | + ref, |
| 49 | + token, |
| 50 | + variables: JSON.stringify(variables) |
69 | 51 | }); |
70 | 52 | } |
71 | 53 |
|
|
87 | 69 | onEmbeddableError={(e) => { |
88 | 70 | console.log(`${e.errorMessage} : ${e.errorDetail}`); |
89 | 71 | }} |
90 | | - token="eyJhbGciOiJIUzI1NiJ9.eyJzZWN1cml0eVRva2VuSWQiOiI1YjBmM2JjMS02ZjUyLTQzZmMtODJkZC1hYWNjZTg2NjRiZTgiLCJpYXQiOjE3MzAzODMyODAsImV4cCI6MTgyMDM4MzI4MH0.NMoOjBNpK2kKxooKNIjiDmWxu1cSN8tywOyuZPw0AkQ" |
| 72 | + token="eyJhbGciOiJIUzI1NiJ9.eyJzZWN1cml0eVRva2VuSWQiOiI4MzNhOGZlMi1mNDI5LTQzMGEtYTc3MC00YzdhN2QyODM3NjYiLCJpYXQiOjE3MzE2MTUzNTMsImV4cCI6MTczMjIyMDE1M30.FDecDdBf-WJlwH6Dh5Jdaztdinjk371w7XhtfsjqaOk" |
91 | 73 | /> |
92 | 74 | </div> |
93 | 75 | </div> |
|
0 commit comments