@@ -10,7 +10,7 @@ Mettle allows developers to declaratively bind the DOM to the underlying instanc
1010function App () {
1111 const msg = signal (' Hello' );
1212
13- return < h1> {msg}< / h1> ;
13+ return < h1> {msg . value }< / h1> ;
1414}
1515```
1616
@@ -20,7 +20,7 @@ function App() {
2020function App () {
2121 const msg = signal (' Hello' );
2222
23- return < input type= ' text' value= {msg} / > ;
23+ return < input type= ' text' value= {msg . value } / > ;
2424}
2525```
2626
@@ -39,7 +39,7 @@ function App() {
3939 return (
4040 <>
4141 < button onClick= {useShow}> show< / button>
42- < div> {isShow ? < p> Mettle .js < / p> : < null >< / null > }< / div>
42+ < div> {isShow . value ? < p> Mettle .js < / p> : < null >< / null > }< / div>
4343 < / >
4444 );
4545}
@@ -63,7 +63,7 @@ function HandleArr() {
6363 <>
6464 < button onClick= {push}> push< / button>
6565 < ul>
66- {arr .map ((item ) => (
66+ {arr .value . map ((item ) => (
6767 < li key= {item}> {item}< / li>
6868 ))}
6969 < / ul>
@@ -106,7 +106,7 @@ function MyComponent() {
106106
107107 return (
108108 <>
109- < p> {count}< / p>
109+ < p> {count . value }< / p>
110110 < button onClick= {add}> MyComponent< / button>
111111 < / >
112112 );
@@ -121,7 +121,7 @@ function App() {
121121
122122 return (
123123 <>
124- < p> {count}< / p>
124+ < p> {count . value }< / p>
125125 < button onClick= {add}> App< / button>
126126 < MyComponent / >
127127 < / >
@@ -220,8 +220,8 @@ function App() {
220220 return (
221221 <>
222222 < button onClick= {add}> Add< / button>
223- < h1 $once> {count}< / h1>
224- < h2> {count}< / h2>
223+ < h1 $once> {count . value }< / h1>
224+ < h2> {count . value }< / h2>
225225 < / >
226226 );
227227}
@@ -263,10 +263,10 @@ function App({ memo }) {
263263 return (
264264 <>
265265 < ul onClick= {handle}>
266- {arr .map ((todo ) => (
266+ {arr .value . map ((todo ) => (
267267 < li
268- $memo= {[todo .id == selected, symbol1]}
269- class = {todo .id == selected ? ' danger' : ' ' }
268+ $memo= {[todo .id == selected . value , symbol1]}
269+ class = {todo .id == selected . value ? ' danger' : ' ' }
270270 key= {todo .id }
271271 data- id= {todo .id }
272272 >
@@ -279,7 +279,7 @@ function App({ memo }) {
279279}
280280```
281281
282- Because the element hit by the ` $memo ` tag will not update its child elements by default, if you want to update it, explicitly define the third item of the array as ` true ` , such as ` $memo={[todo.id == selected, symbol1,true]} ` .
282+ Because the element hit by the ` $memo ` tag will not update its child elements by default, if you want to update it, explicitly define the third item of the array as ` true ` , such as ` $memo={[todo.id == selected.value , symbol1,true]} ` .
283283
284284## Built-in Tags
285285
@@ -298,7 +298,7 @@ function App() {
298298 return (
299299 <>
300300 < button onClick= {useShow}> show< / button>
301- < div> {isShow ? < p> Mettle .js < / p> : < null >< / null > }< / div>
301+ < div> {isShow . value ? < p> Mettle .js < / p> : < null >< / null > }< / div>
302302 < / >
303303 );
304304}
@@ -324,71 +324,3 @@ function App() {
324324 );
325325}
326326```
327-
328- ## Auto-unwrapping
329-
330- When ` Signals ` is accessed in a ` JSX ` template, it is automatically unwrapped, so you no longer need to write ` .value ` for it in the ` JSX ` template.
331-
332- ``` jsx
333- function App () {
334- const count = signal (0 );
335-
336- function add () {
337- count .value ++ ;
338- }
339-
340- return (
341- <>
342- < button onClick= {add}> add< / button>
343- < p> {count}< / p>
344- < / >
345- );
346- }
347- ```
348-
349- However, please note that auto-unwrapping is not possible in the following cases.
350-
351- - Component communication
352-
353- ``` jsx
354- function Child ({ props }) {
355- return < h4> {props .count .value }< / h4> ;
356- }
357-
358- function App () {
359- const count = signal (2 );
360-
361- function increment () {
362- count .value ++ ;
363- }
364-
365- return (
366- <>
367- < button onClick= {increment}> add< / button>
368- < Child count= {count}>< / Child>
369- < / >
370- );
371- }
372- ```
373-
374- - Deep unpacking is not supported
375-
376- ``` jsx
377- const obj = signal ({
378- name: ' hello' ,
379- obj1: {
380- age: 10 ,
381- show: true
382- },
383- });
384-
385- < p> {obj .name }< / p> // Support
386-
387- < p> {obj .obj1 .age }< / p> // Not supported
388- ```
389-
390- - Attribute expressions are not supported.
391-
392- ``` jsx
393- < tr class = {item .id === selected .value ? ' danger' : ' ' }>
394- ```
0 commit comments