Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting occasional mapkit is not defined error #67

Open
pdugan20 opened this issue Jul 21, 2021 · 1 comment
Open

Getting occasional mapkit is not defined error #67

pdugan20 opened this issue Jul 21, 2021 · 1 comment

Comments

@pdugan20
Copy link
Contributor

Occasionally seeing this in sentry logs:
https://sentry.io/share/issue/87d00d547d6d457eb3833070dbe63cf7/

ReferenceError: mapkit is not defined

Seems related to this separate issue:
https://sentry.io/share/issue/0701b217503d42438c008c3209de2333/

TypeError: Cannot read property 'disguiseToken' of undefined

I have a file called MapKitProvider.js:

import dynamic from 'next/dynamic';

const MapkitProvider = dynamic(() =>
    import('react-mapkit').then((mod) => mod.MapkitProvider),
);

export default MapkitProvider;

...which I import at the top of my app:

class HikeAround extends App {
    render() {
        const { Component, pageProps, router, err } = this.props;
        const theme = getTheme();

        return (
            <ToastProvider
                autoDismiss
                autoDismissTimeout={settings.autoDismissTimeout}
                placement={settings.placement}
                components={{ Toast }}
            >
                <ThemeProvider theme={theme}>
                    <MapkitProvider
                        tokenOrCallback={NEXT_PUBLIC_MAPKIT_TOKEN}
                        language={router.locale}
                    >
                        <SimpleReactLightbox>
                            <Component {...pageProps} err={err} />
                        </SimpleReactLightbox>
                    </MapkitProvider>
                </ThemeProvider>
            </ToastProvider>
        );
    }
}

...any ideas?

@chrisdrackett
Copy link
Owner

I don't have a lot of experience with dynamic modules. My first guess is this has something to do with loading apple's javascript. Because apple does not provide mapkit as a module I need to load it via their url. It might be worth loading the mapkit JS yourself https://developer.apple.com/documentation/mapkitjs/loading_the_latest_or_a_specific_version_of_mapkit_js to see if that fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants