Skip to content

TypeError: Cannot read properties of undefined (reading 'ClassEx') #320

@mwbouwkamp-mendix

Description

@mwbouwkamp-mendix

I am trying to wrap kekule into a React widget. I am getting the following error in my console:

TypeError: Cannot read properties of undefined (reading 'ClassEx')
    at kekule.react.base.js:10:22
    at ...

Anyone knows what the problem may be?

Here is my initial (very basic) component:

import { ReactElement, createElement, useState, useRef } from "react";
import { Components } from "kekule-react";

const KekuleComponent = (): ReactElement => {
    const [state, setState] = useState({
        composerPredefinedSetting: 'molOnly',
        chemObj: null
    });

    const composer = useRef<{ getWidget: any }>();

    const onComposerUserModificationDone = () => 
    {
        setState(prevState => {
            return { ...prevState, chemObj: composer.current?.getWidget().getChemObj() }
        });
    }

    return (
        <div>
            <Components predefinedSetting={state.composerPredefinedSetting} onUserModificationDone={onComposerUserModificationDone} />
        </div>
    );
}

export default KekuleComponent;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions