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

Uncaught TypeError: t is undefined #255

Open
jaymzh opened this issue Sep 4, 2023 · 1 comment
Open

Uncaught TypeError: t is undefined #255

jaymzh opened this issue Sep 4, 2023 · 1 comment

Comments

@jaymzh
Copy link

jaymzh commented Sep 4, 2023

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

When I right click, I get Uncaught TypeError: t is undefined - full stack below.

My code is:

const MENU_ID = 'MyMenu'

const MyThing = ({....}) => {
    const { show } = useContextMenu({
        id: MENU_ID,
    });

    ...

    function handleItemClick({ event, props, triggerEvent, data }){
        console.log(event, props, triggerEvent, data );
    }

    return (
        <div>
            ...
            <Menu id={MENU_ID}>
                <Item onClick={handleItemClick}>One</Item>
                <Item onClick={handleItemClick}>Two</Item>
            </Menu>
            <div onContextMenu={show}><p>some stuff here</p></div>
            ...
        </div>
    )
}

When I right click I get this in console:

22:08:38.790 Uncaught TypeError: t is undefined
    show bundle.js:68203
    show bundle.js:68216
    React 14
    unstable_runWithPriority scheduler.development.js:468
    React 15
    js index.js:7
    factory react refresh:6
    Webpack 3
2 bundle.js:68203:5
    show bundle.js:68203
    show bundle.js:68216
    React 14
    unstable_runWithPriority scheduler.development.js:468
    React 8
    forEach self-hosted:4425
    React 7
    js index.js:7
    factory react refresh:6
    Webpack 3

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below:

Sure, though I get a slightly different stack trace (X is not a function) on CodeSandbox: https://codesandbox.io/s/react-contexify-issue-255-t6fthr

What is the expected behavior?

It doesn't fail.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

Firefox 117 (Linux), CodeSandbox.

React 17.0.2, Contexify 6.0.0

@jaymzh
Copy link
Author

jaymzh commented Sep 5, 2023

This seems to be fixed by changing onContextMenu={show} to onContextMenu={(e) => show({event: e})} which I got from the v6-changes page. The tutorial should probably be updated.

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

1 participant