-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
fix(js): Fix key warning in Hook component #88450
Conversation
@@ -51,7 +53,9 @@ function Hook<H extends HookName>({name, ...props}: Props<H>) { | |||
return; | |||
} | |||
|
|||
this.setState({hooks: hooks.map(cb => cb(props))}); |
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.
is it always a component?
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.
Hmm I figured that the point of this was to render getsentry components so I hope so. Maybe I can get the types to validate that
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.
Okay added some type checking, looks like all the current usages are indeed components.
static/app/components/hook.tsx
Outdated
// Only allow hooks that return a React component | ||
type ComponentHookName = { | ||
[K in HookName]: Hooks[K] extends React.ComponentType<any> ? K : never; | ||
}[HookName]; |
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.
nice. this looks right
This was causing console errors in dev anywhere that the
<Hook />
component was being used to render a getsentry component.