TypeError: undefined is not an object (evaluating component.displayName)
2
Hi, I'm having some trouble with a pluggable widget I'm building. When running the dev app locally it immidiately shows this error: TypeError: undefined is not an object (evaluating 'component.displayName' In the modeler log it says this: undefined is not an object (evaluating 'page.$$style') InitAHi.tsx: import { createElement, ReactElement } from "react"; import { TextStyle, ViewStyle} from "react-native"; import { Style } from "@mendix/pluggable-widgets-tools"; import {InitAhiProps} from '../typings/InitAhiProps' import InitAhi from "./components/InitAhi"; export interface CustomStyle extends Style { container: ViewStyle; label: TextStyle; } const InitAhiWrapper = (props: InitAhiProps<CustomStyle>): ReactElement => { return <InitAhi {...props} />; }; export default InitAhiWrapper; compoment called in the above code: const InitAhi = ({ }: InitAhiProps<CustomStyle>): ReactElement => { return ( <Provider store={store}> <ScanMonitor /> <Button title="Press me!" color="#841584" onPress={onPress} /> </Provider> ) } export default InitAhi; For simplicity I trimmed some unrelevant code that get triggered when pressing the button. InitAhi.xml: <?xml version="1.0" encoding="utf-8"?> <widget id="pegamento.initahi.InitAhi" pluginWidget="true" needsEntityContext="true" offlineCapable="true" supportedPlatform="Native" xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../node_modules/mendix/custom_widget.xsd"> <name>Init Ahi</name> <description>Initialise MultiScan SDK</description> <icon/> <properties> <propertyGroup caption="General"> <property key="yourName" type="string" required="false"> <caption>Name</caption> <description>Enter your name</description> </property> <property key="sex" type="attribute"> <caption>Sex</caption> <description>Sex</description> <attributeTypes> <attributeType name="Enum"/> </attributeTypes> </property> <property key="height" type="attribute"> <caption>Height</caption> <description>Height</description> <attributeTypes> <attributeType name="Integer"/> </attributeTypes> </property> <property key="weight" type="attribute"> <caption>Weight</caption> <description>Weight</description> <attributeTypes> <attributeType name="Integer"/> </attributeTypes> </property> <property key="age" type="attribute"> <caption>Age</caption> <description>Age</description> <attributeTypes> <attributeType name="Integer"/> </attributeTypes> </property> <property key="smoker" type="attribute"> <caption>Smoker</caption> <description>Smoker</description> <attributeTypes> <attributeType name="Boolean"/> </attributeTypes> </property> <property key="diabetic" type="attribute"> <caption>Diabetic</caption> <description>Diabetic</description> <attributeTypes> <attributeType name="Boolean"/> </attributeTypes> </property> <property key="hypertension" type="attribute"> <caption>Hypertension</caption> <description>Hypertension</description> <attributeTypes> <attributeType name="Boolean"/> </attributeTypes> </property> <property key="bloodPreassure" type="attribute"> <caption>Blood preassure</caption> <description>Blood preassure</description> <attributeTypes> <attributeType name="Boolean"/> </attributeTypes> </property> </propertyGroup> </properties> </widget> Originally it was exporting a class that extends a Component class. But because is need to use hooks (and those can't be used in classes) I had to convert it to a functional component. To do that I copied some code from a git repo mentioned in this forum post. This error popped up after I did the conversion. Is there something I'm missing?
asked
Reinier Dekker
1 answers
0
I had a similar issue, for some reason mendix app fails when you ‘export default’