-
Notifications
You must be signed in to change notification settings - Fork 843
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
[DISCUSS] Typescript: EuiContextMenuItem icon should be able to be a non-react element #985
Comments
Using But I'm not sure that is the right fix. Icon is used in
So maybe I need to adjust my code to support HTMLElement or SVGElement or ReactElement. |
cc @chandlerprall @cjcenizal and @timroes too - since this might affect you with typings and plugins and needing to support non-react plugin code. |
I was chatting with @timroes and it sounds like |
From @types/react, the ReactNode is Do you have an example of that type working for your needs? |
I can't let the universe not make sense, so digging in... :)
import * as React from "react";
function foo(x: {}) {}
foo(5);
foo({});
foo({a: 'b', c: 3});
foo(NaN);
foo(<div>Hello World</div>);
foo(document.createElement('div')); |
haha. hmmm. well, it'd unblock me? :) So maybe for the time being we could do that in EUI until we figure out a better solution? |
That aside, the component(s) where we want to allow HTML elements to be passed need to be modified to allow it. It makes sense in these cases to have a specific union type, e.g. |
That'll work for me! |
I'm adding functionality that will allow plugins to add menu items. I'm specifying the icon type as
Element | JSX.Element;
. This conflicts with the icon type in eui:export type EuiContextMenuItemIcon = ReactElement<any> | string;
We don't want to force plugins to write their code in react, so I think this type should be more generalized. Open for discussion though.
The text was updated successfully, but these errors were encountered: