0.4.0 • Published 11 months ago

@ivi/identity v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

ivi Identity

Identity component is used to reset internal state.

Example

import { createRoot, update, component, useState, useEffect, html } from "ivi";
import { Identity } from "@ivi/identity";

const Timer = component((c) => {
  const [time, setTime] = useState(c, 0);

  useEffect(c, () => {
    const t = setInterval(() => {
      setTime(time() + 100);
    }, 100);
    return () => { clearInterval(t); };
  })();

  return () => time();
});

const App = component((c) => {
  const [key, setKey] = useState(c, 0);

  const onClick = () => { setKey(key() + 1); };

  return () => (
    html`
    <div class="App">
      <button @click=${onClick}>Next</button>
      ${Identity({ key: key(), children: Timer() })}
    </div>
    `
  );
});

update(
  createRoot(document.body),
  App(),
);
0.4.0-beta.1

11 months ago

0.4.0

11 months ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago