react-chatbot-kit
react-chatbot-kit copied to clipboard
How to call any method of action provider from another react component which is not a widget?
I have react component "Somefile.jsx" from where I am calling <Chatbot> component of react-chatbot-kit. In Somefile.jsx I am calling "abc" method using setInterval to check session timeout. on 6th and 8th min of chat I want to display some session messages in chatbot using createChatbotMessage method. But we cant call this method in Somefile.jsx, because its not declared as widget. Can you please help me with this?
e.g class ActionProvidder{ .... .. abc(idleTime){ if(idleTime == 6) ---> display msg in chatbot } }
In another file Somefile.jsx
class Somefile extends react.Component{
how to call abc() here ???
...... <Chatbot config={config} actionProvide={ActionProvider} messageParser={MessageParsser} }
I'm not an expert, but why not try to use contextAPI. Since its parent, and contextAPI is easy to use. Set actionProvider as globalActionProvider in contextAPI state. so you can access it anywhere. Or any other state manager.