Preserve reactivity in Solid example component (#5386)

This commit is contained in:
Josh Wilson 2022-11-13 22:50:15 -05:00 committed by GitHub
parent df8092b007
commit eab4a0279f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
import { createSignal } from 'solid-js'; import { createSignal } from 'solid-js';
import './Counter.css'; import './Counter.css';
export default function Counter({ children }) { export default function Counter(props) {
const [count, setCount] = createSignal(0); const [count, setCount] = createSignal(0);
const add = () => setCount(count() + 1); const add = () => setCount(count() + 1);
const subtract = () => setCount(count() - 1); const subtract = () => setCount(count() - 1);
@ -13,7 +13,7 @@ export default function Counter({ children }) {
<pre>{count()}</pre> <pre>{count()}</pre>
<button onClick={add}>+</button> <button onClick={add}>+</button>
</div> </div>
<div class="counter-message">{children}</div> <div class="counter-message">{props.children}</div>
</> </>
); );
} }