{"record":{"id":"65cd60bfe6c24782","repo":"ianstormtaylor/slate","slug":"the-ref-prop-of-a-token-cannot-be-used-with-the-pa","errorCode":null,"errorMessage":"The ref prop of a token cannot be used with the path prop.","messagePattern":"The ref prop of a token cannot be used with the path prop\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/slate-hyperscript/src/tokens.ts","lineNumber":44,"sourceCode":"export class Token<Ref = unknown> {\n  offset?: number\n  path?: Path\n  ref?: Ref\n\n  constructor(\n    props: {\n      offset?: number\n      path?: Path\n      ref?: Ref\n    } = {}\n  ) {\n    const { offset, path, ref } = props\n    this.offset = offset\n    this.path = path\n\n    if (ref) {\n      if (path != null) {\n        throw new Error(\n          'The ref prop of a token cannot be used with the path prop.'\n        )\n      }\n      this.ref = ref\n    }\n  }\n}\n\n/**\n * Anchor tokens represent the selection's anchor point.\n */\n\nexport class AnchorToken extends Token<HyperscriptRangeRef> {}\n\n/**\n * Focus tokens represent the selection's focus point.\n */\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/ianstormtaylor/slate/blob/72a37c701e5da4bb13a305d416d9c070d19d3a45/packages/slate-hyperscript/src/tokens.ts#L26-L62","documentation":"In slate-hyperscript token tags (<text>, <inline>, <block>, etc.), a ref prop and a path prop are mutually exclusive. The ref mechanism works by having the token record the path where it ends up in the editor tree at render time, while path explicitly hardcodes the location. Passing both is contradictory, so the token constructor throws immediately.","triggerScenarios":"Writing <text path={[0,0]} ref={t}>hi</text>; passing a props object containing both path and ref to any token tag created by createHyperscript.","commonSituations":"Migrating old tests that used explicit path props and adding refs without removing path; copy-pasting token markup and forgetting to delete the path prop.","solutions":["Remove the path prop and let the ref capture the path from the editor tree","Or remove the ref prop and keep using the explicit path if you don't need a ref object"],"exampleFix":"// before\n<editor>\n  <text path={[0]} ref={t}>hello</text>\n</editor>\n\n// after\n<editor>\n  <text ref={t}>hello</text>\n</editor>","handlingStrategy":"validation","validationCode":"if (props.ref != null && props.path != null) {\n  throw new Error('ref and path are mutually exclusive on tokens')\n}\n// before rendering the token","typeGuard":"const hasConflictingProps = (p) =>\n  p.ref != null && p.path != null","tryCatchPattern":null,"preventionTips":["Never combine path and ref on slate-hyperscript token tags","Prefer refs over hardcoded paths in modern tests"],"tags":["slate-hyperscript","tokens","conflicting-props","testing"],"backgroundTag":"conflicting-props-validation","analyzedSha":"72a37c701e5da4bb13a305d416d9c070d19d3a45","analyzedAt":"2026-08-27T23:04:51.145Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}