-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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: Don't crash when hovering hotbar menu index #7707
Conversation
I don't understand. Why is |
packages/core/src/renderer/components/custom-resources/crd-resources.tsx
Outdated
Show resolved
Hide resolved
footer?: React.ReactNode; | ||
children?: React.ReactNode | React.ReactNode[]; | ||
footer?: SafeReactNode; | ||
children?: SingleOrMany<SafeReactNode>; |
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.
React.ReactNode
is enough
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.
No it is not, but SafeReactNode
(or StrictReactNode
)
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.
- We shouldn't introduce new type for
ReactNode
which is somehow magically safer than the original. If the motivation is to prevent developer from forgetting to add.get()
to observable, then we have bigger issues... This would mean that developer has never tried the change because there's no way that it would ever work properly. Also unit tests would catch it. SingleOrMany
is unnecessary becauseReactNode
accepts array of react nodes by default.- Usage of
React.Children.toArray
is unnecessary because{children}
would be enough. There's only one change in implementation and that doesn't have anything to do with hotbar, so how could it solve something for hotbar?- Unit tests for the fix?
It would seem to me that here the medicine of introducing custom types for a very specific purpose is worse than the sickness of forgetting to use an I propose adding said unit tests, doing the following actual fix, and calling it done.
|
I propose also adding unit tests, but keeping the safer types as additional safety. |
}; | ||
}; | ||
|
||
export type StrictReactNode = |
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.
It would make sense for react itself to expose this typing. Weird stuff.
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.
Yeah..., might not be needed in react 18 but since we are in react 17 still that might be the problem.
| Iterable<StrictReactNode> | ||
| boolean | ||
| null | ||
| undefined; |
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.
Even if react 18 now permits rendering undefined
, should we internally advocate that? WDYT?
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.
Probably a good idea to remove, will try it.
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.
Ok with unit tests.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
- Remove all uses of React.ReactNode as it is unsafe, replace them with usages of SafeReactNode which doesn't contain the '{}' type Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
…rces Signed-off-by: Sebastian Malton <sebastian@malton.name>
0a63c75
to
7a65887
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
Signed-off-by: Sebastian Malton <sebastian@malton.name>
closes #7703