{"record":{"id":"597bda4d5ea907bb","repo":"ianstormtaylor/slate","slug":"a-hyperscriptpointref-must-be-passed-as-the-ref-pr","errorCode":null,"errorMessage":"A HyperscriptPointRef must be passed as the ref prop of a <point /> tag that is used inside an <editor>.","messagePattern":"A HyperscriptPointRef must be passed as the ref prop of a <point /> tag that is used inside an <editor>\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/slate-hyperscript/src/refs.ts","lineNumber":16,"sourceCode":"import { Path, Point, Range } from 'slate'\n\n/**\n * Hyperscript point refs can be used to construct arbitrary points using the\n * ref prop of a <point /> tag.\n */\n\nexport class HyperscriptPointRef {\n  path?: Path\n  offset?: number\n\n  point(): Point {\n    const { path, offset } = this\n\n    if (path == null || offset == null) {\n      throw new Error(\n        'A HyperscriptPointRef must be passed as the ref prop of a <point /> tag that is used inside an <editor>.'\n      )\n    }\n\n    return { path, offset }\n  }\n}\n\n/**\n * Hyperscript range refs can be used to construct arbitrary range using the ref\n * props of <anchor /> and <focus /> tags.\n */\n\nexport class HyperscriptRangeRef {\n  anchor?: Point\n  focus?: Point\n\n  range(): Range {","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/ianstormtaylor/slate/blob/72a37c701e5da4bb13a305d416d9c070d19d3a45/packages/slate-hyperscript/src/refs.ts#L1-L34","documentation":"In slate-hyperscript, a <point ref={...}/> tag's ref only accumulates a path and offset when the tag is used inside an <editor> element. When the tag is used outside an <editor> (e.g., inside a plain <value>, <fragment>, or <text> tag), the ref never receives a path/offset, and calling .point() on the ref throws this error. The library throws it because a Point requires both a path and an offset, and neither can be inferred outside of an editor's tree context.","triggerScenarios":"Creating a hyperscript tag creator without registering 'editor' among elements (e.g. createHyperscript({ elements: { point: ... } }) without editor), placing <point ref={p}/> inside <fragment> or <element> instead of <editor>, or calling p.current.point() on a ref that was never rendered inside an editor.","commonSituations":"Test files that build standalone fragments with points in them; upgrading slate-hyperscript where the default elements set changed; forgetting that the ref's point() only works post-render inside an editor.","solutions":["Move the <point ref={p}/> tag inside an <editor>...</editor> tag so it gets a path and offset assigned","Ensure 'editor' is included in the elements option of createHyperscript (it is part of the default set)","If you only need a path/offset outside an editor, pass explicit path/offset props or construct the Point object manually instead of using a ref"],"exampleFix":"// before\nconst fragment = (\n  <fragment>\n    <point ref={start} />\n    <text>hello</text>\n  </fragment>\n)\nconst p = start.current.point() // throws\n\n// after\nconst value = (\n  <editor>\n    <point ref={start} />\n    <text>hello</text>\n  </editor>\n)\nconst p = start.current.point() // works","handlingStrategy":"validation","validationCode":"if (start.current?.path != null && start.current?.offset != null) {\n  const p = start.current.point()\n}","typeGuard":"const hasPoint = (r) =>\n  r != null && r.path != null && r.offset != null","tryCatchPattern":null,"preventionTips":["Always render <point ref/> tags inside an <editor> element","Keep 'editor' in the createHyperscript elements set"],"tags":["slate-hyperscript","refs","point","jsx","testing"],"backgroundTag":"invalid-hyperscript-usage","analyzedSha":"72a37c701e5da4bb13a305d416d9c070d19d3a45","analyzedAt":"2026-08-27T23:04:51.145Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}