useOverlay
useOverlay(options) manages the lifecycle of an overlay. It’s the hook equivalent of <KLineChart.Overlay>.
import { useOverlay } from "react-klinecharts";
function MyOverlay() { const id = useOverlay({ value: { name: "priceLine", points: [{ value: 50000 }] } }); return null;}Signature
Section titled “Signature”function useOverlay(options: UseOverlayOptions): Nullable<string> | Array<Nullable<string>>Returns the overlay id (or an array of ids for batch creation).
Options
Section titled “Options”| Option | Type | Description |
|---|---|---|
value |
string | OverlayCreate | Array<string | OverlayCreate> |
Overlay name, config, or batch array. |
Behavior
Section titled “Behavior”- Creates the overlay(s) on mount via
createOverlay(value). - Overrides config when
valuechanges for single object configs (skips the first run). - Removes the overlay(s) on unmount.