Uncaught TypeError: window.Intercom is not a function

Viewed 1275

I am working typescript react project. This project use webpack.
I have Uncaught TypeError: Window.Intercpm in not a function.
I have tried several times, but I can't find cause of this error.\

Uncaught TypeError: window.Intercom is not a function
    at Object../src/index.tsx (index.tsx:30)
    at __webpack_require__ (bootstrap 990f71972c97638bc359:678)
    at fn (bootstrap 990f71972c97638bc359:88)
    at Object.0 (window.ts:32)
    at __webpack_require__ (bootstrap 990f71972c97638bc359:678)
    at bootstrap 990f71972c97638bc359:724
    at bootstrap 990f71972c97638bc359:724

Error location : index.tsx:30
index.tsx is following

import bugsnag from '@bugsnag/js'
import bugsnagReact from '@bugsnag/plugin-react'
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { AppContainer } from 'react-hot-loader'
import 'bootstrap/dist/css/bootstrap.min.css'
import Root from './Root'

    const bugsnagClient = bugsnag('*********************************')
    bugsnagClient.use(bugsnagReact, React)
    const ErrorBoundary = bugsnagClient.getPlugin('react')
    const rootEl = document.getElementById('root')
    ReactDOM.render(
        <AppContainer>
            <ErrorBoundary>
                <Root/>
            </ErrorBoundary>
        </AppContainer>,
        rootEl
    )
    // Load Intercom
    declare global {
        interface Window {
            Intercom: any
        }
    }
    window.Intercom('boot', {app_id: '********'})
    // Hot Module Replacement API
    if (module.hot) {   
        module.hot.accept('./containers/Root', () => {
            const NextApp = require<{ default: typeof Root }>('./containers/Root').default
            ReactDOM.render(
                <AppContainer>
                    <ErrorBoundary>
                        <NextApp/>
                    </ErrorBoundary>
                </AppContainer>,
                rootEl
            )
        })
    }

I think there are methods that this bug fix.

0 Answers
Related