-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Upgraded @deephaven/jsapi-types to 1.0.0-dev0.33.2 (#389) #390
Conversation
@@ -22,7 +22,7 @@ function ObjectView(props: ObjectViewProps) { | |||
() => | |||
[...plugins.values()] | |||
.filter(isWidgetPlugin) | |||
.find(p => [p.supportedTypes].flat().includes(object.type)), | |||
.find(p => [p.supportedTypes].flat().includes(object.type as string)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of casting here... Above I'd just set type
and then just check if it's null
before going through plugins (since we will never be able to open the object if the type isn't defined). Also there's a object == null
check that doesn't make sense below (since it's always defined).
So something like :
const { object } = props;
const { type } = object;
...
const plugin = useMemo(
() =>
type != null ? [...plugins.values()]
.filter(isWidgetPlugin)
.find(p => [p.supportedTypes].flat().includes(type)) : undefined,
[plugins, type]
);
|
||
const Component = getSpectrumComponent(name) as | ||
| React.ComponentType<unknown> | ||
| undefined; | ||
|
||
if (Component == null) { | ||
throw new Error(`Unknown Spectrum component ${name}`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, we should throw
in getSpectrumComponent
if there is no type returned. Then this is just const Component = getSpectrumComponent(name)
and it all makes sense.
const openedMetadataRef = useRef<ReactPanelControl['metadata'] | null>( | ||
portal != null ? metadata : null | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh good catch. I would've just returned undefined
instead of null
, since that matches the ReactPanelControl['metadata']
type already.:
const openedMetadataRef = useRef<ReactPanelControl['metadata'] | null>( | |
portal != null ? metadata : null | |
); | |
const openedMetadataRef = useRef<ReactPanelControl['metadata']>( | |
portal != null ? metadata : undefined | |
); |
resolves #389