useNarabefunction
One game, kept in React state.
settings is read when the hook first runs and again on reset; give it a
seed for a game that starts the same way every time.
Import it
import { useNarabe } from "@johnmorrisdotca/narabe/react";
Definition
function useNarabe(settings?: Partial<GameSettings>): NarabeGame
Parameters
| Name | Type | Description |
|---|---|---|
settings (optional) | Partial<GameSettings> | The native game settings to interpret. |
Returns
NarabeGame
The current position, available choices and native action callbacks.
Examples
import { createElement } from "react";
import { useNarabe } from "@johnmorrisdotca/narabe/react";
function Board() {
const game = useNarabe({variant:"reversi"});
return createElement("p",null,game.state.toPlay);
}
console.log(createElement(Board));