I am encountering difficulties while attempting to utilize signals in my React application with Vite. I am testing the usability of signals using the example provided in the documentation, but unfortunately, the UI does not update as expected.
import { signal } from "@preact/signals-react";
export const SimpleComponent = () => {
const count = signal(0);
const value = count.value;
const increment = () => {
console.log(count.value); // Correctly logs the value
// The UI does not update even though the value is changed
count.value = 10 * Math.random();
};
return (
<div>
{value}
<button onClick={increment}></button>
</div>
);
};
The UI does not reflect changes when the button is clicked, even though console.log(count.value) correctly displays the updated value in the console.
I suspect there might be an issue with the way signals are being used or updated in the React component.
I am encountering difficulties while attempting to utilize signals in my React application with Vite. I am testing the usability of signals using the example provided in the documentation, but unfortunately, the UI does not update as expected.
The UI does not reflect changes when the button is clicked, even though console.log(count.value) correctly displays the updated value in the console. I suspect there might be an issue with the way signals are being used or updated in the React component.
Can you help me troubleshoot this issue?