Skip to content

Commit

Permalink
misc post-rebase fixes for OperatorIO
Browse files Browse the repository at this point in the history
  • Loading branch information
imanjra committed Aug 13, 2024
1 parent c7613b3 commit d45dcbd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 7 additions & 11 deletions app/packages/core/src/plugins/SchemaIO/components/DynamicIO.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PluginComponentType, useActivePlugins } from "@fiftyone/plugins";
import { isNullish } from "@fiftyone/utilities";
import { get, isEqual, set } from "lodash";
import { useEffect, useMemo } from "react";
import React, { useEffect, useMemo } from "react";
import { isPathUserChanged, useUnboundState } from "../hooks";
import {
getComponent,
Expand Down Expand Up @@ -62,24 +62,19 @@ function useCustomComponents() {

// todo: need to improve initializing the state... refactor this function
function useStateInitializer(props: ViewPropsType) {
const { data, schema, onChange, path, root_id } = props;
const { data, schema, onChange } = props;
const computedSchema = getComputedSchema(props);
const { default: defaultValue } = computedSchema;
const basicData = useMemo(() => {
if (!isCompositeView(schema)) {
return data;
}
}, [data, schema]);
const unboundState = useUnboundState({
computedSchema,
data,
path,
root_id,
props,
});
const unboundState = useUnboundState({ computedSchema, props });

useEffect(() => {
const { computedSchema, data, path, root_id, props } = unboundState || {};
const { computedSchema, props } = unboundState || {};
const { data, path, root_id } = props || {};
if (
!isCompositeView(computedSchema) &&
!isEqual(data, defaultValue) &&
Expand All @@ -93,7 +88,8 @@ function useStateInitializer(props: ViewPropsType) {

useEffect(() => {
if (basicData) {
const { computedSchema, path, data } = unboundState || {};
const { computedSchema, props } = unboundState || {};
const { data, path } = props || {};
if (
!isEqual(data, basicData) &&
!isCompositeView(computedSchema) &&
Expand Down
2 changes: 1 addition & 1 deletion app/packages/core/src/plugins/SchemaIO/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ export function isCompositeView(schema: SchemaType) {
}

export function isInitialized(props: ViewPropsType) {
const { initialData, path } = props;
const { initialData, path } = props || {};
return !isNullish(get(initialData, path));
}

0 comments on commit d45dcbd

Please sign in to comment.