Closed medicareamaze closed 5 years ago
@medicareamaze please provide the full traceback.
@medicareamaze You can restrict code to run only on the client or on the server by using some special globals that is in place:
SERVER and CLIENT
So you can do something like is done here: https://github.com/plone/volto/blob/d2e2453359f03dd1f23f3b3a074ce06a17302db3/src/components/manage/Preferences/PersonalPreferences.jsx#L180
Question answered. Closing. Feel free to re-open if you disagree.
@sneridagh , Sorry for the delayed response. The problem was with import statement - I could not even add an import statement that referenced the Microsoft Bot framework library. I eneded up using require as follows
componentDidMount() {
this.setState({ WebChat: require('./WebChat').WebChat });
let obj = require('botframework-webchat')
this.setState({
styleSet: obj.createStyleSet({
backgroundColor: 'Transparent'
})
});`
this.setState({ showChat: true });
}
render() {
return (
{
showChat ?
<WebChat
className="react-web-chat"export class WebChat
onFetchToken={ this.handleFetchToken }
store={ store }
styleSet={ styleSet }
token={ token }
user = { user }
/>
:
'Loading Chat'
}
)
}
Hi, I am extending the custom View example to add a Microsoft bot react component following this tutorial - https://plone-training.readthedocs.io/en/master/volto/custom-views.html.
This gives an error stating that window is not defined. This is because the microsoft bot chat control cannot be rendered server side and should be rendered on client side only.
How can I force Volto to render this control on client side only and get past this issue?
My Code is as follows: