useSyncExternalStore

Allows you to subscribe to an external store and read the current state synchronously. It's particularly useful when you are working with state management libraries or any custom external store where you need to synchronize the Kaioken component with the store's state.

Example

import { useSyncExternalStore } from "kaioken"
import { counterStore } from "./counterStore"

function App() {
  // Using useSyncExternalStore to subscribe to the counter store
  const count = useSyncExternalStore(
    counterStore.subscribe, // Subscribe function
    counterStore.getState // Get current state function
  )

  return (
    <div>
      <h1>Count: {count}</h1>
      <button onclick={counterStore.increment}>Increment</button>
    </div>
  )
}