0

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.

1 Answer 1

0

You haven't followed the usage instructions. Please read the Integration Instructions and use the Babel plugin or useSignals().

Sign up to request clarification or add additional context in comments.

1 Comment

I see! Im sorry, I didnt see this part of docs, mb! Thank you so much for giving me this information, it worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.