feat(flow): Narrow options type for useNodesState/useEdgesState/useElementsState

* remove storageKey
* make modelValue optional

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-12-20 19:29:52 +01:00
parent ee6bf3252e
commit a9e7eb31ea
8 changed files with 42 additions and 27 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ export default (
nodes,
edges,
}: {
modelValue?: Ref<Elements>
modelValue?: Ref<Elements | undefined>
nodes?: Ref<Node[] | undefined>
edges?: Ref<Edge[] | undefined>
},
@@ -16,7 +16,7 @@ export default (
store: FlowStore,
) => {
if (isDefined(props.modelValue)) {
const { pause, resume } = pausableWatch([() => props.modelValue, () => props.modelValue.length], async ([v]) => {
const { pause, resume } = pausableWatch([() => props.modelValue, () => props.modelValue?.length], async ([v]) => {
if (v && Array.isArray(v)) {
pause()
store.setElements(v)