react-chatbot-kit
react-chatbot-kit copied to clipboard
TypeError: Cannot read properties of undefined (reading 'createChatBotMessage') Possible NextJS issue?
When attempting to trigger an actionprovider method from a widget button I keep getting this error. If I call the method using messageparser the method works as expected. Only when calling the method from a widget does the error occur.
This could be a known NextJS issue although I didn't see it in the open issues... Or I may have something configured wrong.
Here is where the method is defined in the actionprovider:
here is where its called in widget options:
and this is a copy of the error:
any ideas or suggestions would great! Thanks!
Hi. Can you provide a reproducable example or steps to reproduce this error?
I'm facing same kind of error TypeError: Cannot read properties of undefined (reading 'actionProvider')
`import React from "react";
const ActionProvider = ({ createChatBotMessage, setState, children }) => { const handleHello = () => { const botMessage = createChatBotMessage("Hello. Nice to meet you.");
setState((prev) => ({
...prev,
messages: [...prev.messages, botMessage],
}));
};
const handleDog = () => { const botMessage = createChatBotMessage( "Here's a nice dog picture for you!", { widget: "dogPicture", }, );
setState((prev) => ({
...prev,
messages: [...prev.messages, botMessage],
}));
};
const handleJavascriptList = () => { const message = this.createChatBotMessage( "Fantastic, I've got the following resources for you on Javascript:", { widget: "javascriptLinks", }, );
this.updateChatbotState(message);
};
return (
export default ActionProvider; `