I have small project compost by only a App.JSX
that works 100%, but I need to turn it in to App.TSX
.
When I change the extension to .TSX
, I get two errors, I don't know how to deal with them.
function MyComponentWithIconProps(props) {
. This one seems to be fixed by adding a:any
at the end ofprops
.
(parameter) props: any
Parameter 'props' implicitly has an 'any' type.ts(7006)
DoneIcon
in<MyComponentWithIconProps statusImage={DoneIcon} />
I don't have any idea how to deal with this one.
(alias) const DoneIcon: OverridableComponent<SvgIconTypeMap<{}, "svg">> & {
muiName: string;
}
import DoneIcon
Demos:
Icons
Material Icons
API:
SvgIcon API
Type 'OverridableComponent<SvgIconTypeMap<{}, "svg">> & { muiName: string; }' is not assignable to type 'ReactElementLike | null | undefined'.
Type 'OverridableComponent<SvgIconTypeMap<{}, "svg">> & { muiName: string; }' is missing the following properties from type 'ReactElementLike': type, props, keyts(2322)
App.tsx(21, 47): Did you mean to call this expression?
Small and full project file:
import DoneIcon from "@mui/icons-material/Done";
import PropTypes from "prop-types";
function MyComponentWithIconProps(props) {
const StatusImage = props.statusImage;
return (
<div>
<StatusImage />
</div>
);
}
MyComponentWithIconProps.propTypes = {
statusImage: PropTypes.element,
};
function App() {
return (
<>
<div className="App">
<MyComponentWithIconProps statusImage={DoneIcon} />
</div>
</>
);
}
export default App;