SvenKirschbaum / react-stomp-hooks

This repository contain a react library which enables simple access to stomp subscriptions via hooks.
MIT License
59 stars 12 forks source link

global is not defined #20

Closed jelle-blaauw closed 1 year ago

jelle-blaauw commented 1 year ago

I'm getting the following error:

image

My source:

import {StompSessionProvider} from "react-stomp-hooks";

// ...

<StompSessionProvider
    url={"https://stream.elite12.de/api/sock"}
    debug={(str) => {
        console.log(str);
    }}>
    <Router>
        <Box sx={{display: 'flex', width: '100%', height: '100%'}}>
            <NavigationBar/>
            <Box
                component="main"
                sx={{
                    flexGrow: 1,
                    p: {md: 3},
                    // width: {sm: `calc(100% - ${drawerWidth}px)`},
                    width: '100%',
                    height: '100%',
                    backgroundColor: (theme: Theme) => theme.palette.mode === 'dark' ? theme.palette.background.paper : '#f5f5f5'
                }}>
                <Toolbar/>
                <PageContainer>
                    <Suspense fallback={<div>Loading...</div>}>
                        <MainPage/>
                    </Suspense>
                </PageContainer>
            </Box>
        </Box>
    </Router>
</StompSessionProvider>

I've tried manually adding the sockjs-client dependency, but it made no difference. Any ideas?

SvenKirschbaum commented 1 year ago

Hello!

Please take a look at this issue: https://github.com/sockjs/sockjs-client/issues/439

This is not an issue with react-stomp-hooks itself, and likely connected to your build setup.

danibiro commented 1 month ago

Same error. I am not using sockjs; I get the same error without any config.

SvenKirschbaum commented 2 weeks ago

I have just released version 3.0.0, which includes a workaround for this issue.