I have an array signals that are being rendered in UI using map, but everytime I put a new value in it, it doesnt rerender and show in UI the new value.
import React from "react";
import { signal, effect } from "@preact/signals-react";
let varA = 0
const count = signal([0]);
const App = () => {
effect(() => console.log(count.value));
return (
<div>
<ul>
{count.value.map((count) => { return <li key={varA++}>{count}</li> })}
</ul>
<button onClick={() => count.value = [...count.value, 1]}>{count}</button>
</div>
)
};
export default App
Id like to know how to make it work.
You haven't followed the usage instructions. Please read the Integration Instructions and use the Babel plugin or
useSignals()
.