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

Cannot use with Snowpack: Uncaught TypeError: Cannot convert undefined or null to object #315

Closed
looeee opened this issue Feb 27, 2022 · 0 comments

Comments

@looeee
Copy link

looeee commented Feb 27, 2022

EDIT: Looks like this is a problem with @use-gesture/react, Reported there instead: pmndrs/use-gesture#451. The Snowpack issue has been updated to reflect this.

Attempting to render Leva components in Snowpack results in a TypeError. The same code in CRA or standard Codesand react template renders correctly.

Codesandbox with snowpack
Standard react codesandbox

import { render } from "react-dom";
import { useControls } from "leva";
import React from "react";

const App = () => {
  const controls = useControls({
    Checked: true
  });

  return (
    <code>
      <pre>{JSON.stringify(controls, null, " ")}</pre>
    </code>
  );
};

render(<App />, document.getElementById("root"));

Expected result:
expected

Actual result
error

Full error:

Uncaught TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at resolveWith (@use-gesture.core.v10.2.6.js:573:40)
    at parse (@use-gesture.core.v10.2.6.js:618:27)
    at Controller.applyConfig (@use-gesture.core.v10.2.6.js:738:19)
    at useRecognizers (@use-gesture.react.v10.2.6.js:11:8)
    at useDrag (@use-gesture.react.v10.2.6.js:26:10)
    at useDrag (leva.v0.9.23.js:1421:10)
    at TitleWithFilter (leva.v0.9.23.js:4231:16)
    at renderWithHooks (react-dom.v17.0.2.js:14989:18)
    at mountIndeterminateComponent (react-dom.v17.0.2.js:17815:13)
client-hook-6.js:1 The above error occurred in the <TitleWithFilter> component:

    at TitleWithFilter (https://l9gmzc.sse.codesandbox.io/_snowpack/pkg/leva.v0.9.23.js:4216:3)
    at div
    at Styled.div
    at https://l9gmzc.sse.codesandbox.io/_snowpack/pkg/leva.v0.9.23.js:4350:3
    at LevaRoot (https://l9gmzc.sse.codesandbox.io/_snowpack/pkg/leva.v0.9.23.js:4315:5)
    at Leva (https://l9gmzc.sse.codesandbox.io/_snowpack/pkg/leva.v0.9.23.js:4414:5)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
r.<computed> @ client-hook-6.js:1
scheduler.v0.20.2.js:163 Uncaught TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at resolveWith (@use-gesture.core.v10.2.6.js:573:40)
    at parse (@use-gesture.core.v10.2.6.js:618:27)
    at Controller.applyConfig (@use-gesture.core.v10.2.6.js:738:19)
    at useRecognizers (@use-gesture.react.v10.2.6.js:11:8)
    at useDrag (@use-gesture.react.v10.2.6.js:26:10)
    at useDrag (leva.v0.9.23.js:1421:10)
    at TitleWithFilter (leva.v0.9.23.js:4231:16)
    at renderWithHooks (react-dom.v17.0.2.js:14989:18)
    at mountIndeterminateComponent (react-dom.v17.0.2.js:17815:13)

Also reported on snowpack repo: FredKSchott/snowpack#3878

@looeee looeee closed this as completed Feb 27, 2022
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