@choo-choo/react
v0.1.3
Published
React binding for choo-choo: the <ChooChoo> component, SSR-safe and hook-free.
Maintainers
Readme
@choo-choo/react
React binding for Choo Choo: a <ChooChoo> component that renders a railroad diagram from a grammar source or a pre-built IR. SSR-safe, hook-free.
Install
npm install @choo-choo/reactPlus one grammar parser of your choice if you want to pass a source:
npm install @choo-choo/parser-ebnfExample
import { ChooChoo } from "@choo-choo/react";
import { ebnfParser } from "@choo-choo/parser-ebnf";
const source = `
digit = "0" | "1" ;
pair = digit , digit ;
`;
export function Example() {
return (
<ChooChoo source={source} parser={ebnfParser} rule="pair" />
);
}You can also skip the parser and pass a pre-built IR via the ir prop — handy if you construct diagrams with @choo-choo/core's builder API.
Learn more
License
MIT
