Unable to use Custom Button
dave-smartystreets opened this issue · 6 comments
dave-smartystreets commented
This code from the README.md
file...
import { useChat } from 'react-live-chat-loader'
export const LoadChatButton = () => {
const [state, loadChat] = useChat()
return <button onClick={loadChat}>Load Chat</button>
}
... throws the following error:
Server Error
TypeError: Cannot destructure property 'loadWhenIdle' of 'undefined' as it is undefined.
mikedijkstra commented
Can you confirm what Provider you are using? A complete example of your implementation with the Provider wrapping the hook will be helpful for us to debug.
dave-smartystreets commented
Sure thing. We're using HelpScout.
mikedijkstra commented
Thanks. I can reproduce the bug. We seem to have lost the default value in the Typescript update. For now you can get around this by passing in an empty object or an object with loadWhenIdle
set to false
so it'll only load when you click your button. e.g.
const [state, loadChat] = useChat({})
const [state, loadChat] = useChat({loadWhenIdle: false})
dave-smartystreets commented
Awesome, thanks for the help!
elmoeleven commented
Whoops, @mikedijkstra I'll open up a PR to fix it.
mikedijkstra commented
@elmoeleven Great! I was just about to add another issue but won't do that now 😄