|
20 | 20 | import React from 'react'; |
21 | 21 | import {useState, useEffect, useRef} from 'react'; |
22 | 22 | import {shallowEqualArrays} from 'shallow-equal'; |
23 | | -import {getIn, entries, applyPatches, zoomOutPatches, SET} from 'dendriform-immer-patch-optimiser'; |
| 23 | +import {getIn, getType, entries, applyPatches, zoomOutPatches, SET, BASIC} from 'dendriform-immer-patch-optimiser'; |
24 | 24 | import type {Path} from 'dendriform-immer-patch-optimiser'; |
25 | 25 | import produce, {isDraft, original} from 'immer'; |
26 | 26 | import {producePatches, Patch} from './producePatches'; |
@@ -697,6 +697,9 @@ const Branch = React.memo( |
697 | 697 | (prevProps, nextProps) => shallowEqualArrays(prevProps.deps, nextProps.deps) |
698 | 698 | ); |
699 | 699 |
|
| 700 | +// eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 701 | +const branchable = (thing: any) => getType(thing) !== BASIC; |
| 702 | + |
700 | 703 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
701 | 704 | const entriesOrDie = (thing: any, error: ErrorKey) => { |
702 | 705 | try { |
@@ -813,6 +816,10 @@ export class Dendriform<V,P extends Plugins = undefined> { |
813 | 816 | return this.core.applyIdToPlugins(this.id, this.path) as P; |
814 | 817 | } |
815 | 818 |
|
| 819 | + get branchable(): boolean { |
| 820 | + return branchable(this.value); |
| 821 | + } |
| 822 | + |
816 | 823 | set = (toProduce: ToProduce<V>, options: SetOptions = {}): void => { |
817 | 824 | this.core.setWithDebounce(this.id, toProduce, options); |
818 | 825 | }; |
|
0 commit comments