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

ViteJS build produces error when using ThemeContext #7122

Open
sdosch opened this issue Feb 7, 2024 · 0 comments
Open

ViteJS build produces error when using ThemeContext #7122

sdosch opened this issue Feb 7, 2024 · 0 comments
Labels
bug issue that does not match design or documentation and requires code changes to address

Comments

@sdosch
Copy link

sdosch commented Feb 7, 2024

There seems to be an incompatibility with ViteJS and when using Grommet ThemeContext.

Expected Behavior

Using ThemeContext inside a ViteJS environment should work as it does currently with Create React App.

Actual Behavior

Using ThemeContext will produce a compile error after building the project via vite build.

Steps to Reproduce

import { Box, Grommet, ThemeContext } from "grommet";

export default function App(): JSX.Element {
  return (
    <Grommet>
      <ThemeContext.Extend
        value={{
          global: {
            colors: { doc: "#ff99cc" },
          },
        }}
      >
        <Box pad="large" background="doc" />
      </ThemeContext.Extend>
    </Grommet>
  );
}
  • build the project for production (vite build)
  • locally preview production build (vite preview)
  • produces Minified React error:
index-1uIJSkDh.js:4271 Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at yh (index-1uIJSkDh.js:7185:17)
    at J2 (index-1uIJSkDh.js:3679:113)
    at Yi (index-1uIJSkDh.js:4342:27)
    at Zi (index-1uIJSkDh.js:4354:3)
    at Wk (index-1uIJSkDh.js:6986:92)
    at Vk (index-1uIJSkDh.js:6569:12)
    at Uk (index-1uIJSkDh.js:6562:5)
    at Jk (index-1uIJSkDh.js:6545:7)
    at Ok (index-1uIJSkDh.js:6261:7)
    at Hk (index-1uIJSkDh.js:6192:54)
Mi @ index-1uIJSkDh.js:4271
Oi.c.callback @ index-1uIJSkDh.js:4286
ih @ index-1uIJSkDh.js:3335
lk @ index-1uIJSkDh.js:5960
jk @ index-1uIJSkDh.js:5920
ik @ index-1uIJSkDh.js:5897
Xk @ index-1uIJSkDh.js:6655
Qk @ index-1uIJSkDh.js:6611
Hk @ index-1uIJSkDh.js:6208
J2 @ index-1uIJSkDh.js:491
R2 @ index-1uIJSkDh.js:521
index-1uIJSkDh.js:7185 Uncaught Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at yh (index-1uIJSkDh.js:7185:17)
    at J2 (index-1uIJSkDh.js:3679:113)
    at Yi (index-1uIJSkDh.js:4342:27)
    at Zi (index-1uIJSkDh.js:4354:3)
    at Wk (index-1uIJSkDh.js:6986:92)
    at Vk (index-1uIJSkDh.js:6569:12)
    at Uk (index-1uIJSkDh.js:6562:5)
    at Jk (index-1uIJSkDh.js:6545:7)
    at Ok (index-1uIJSkDh.js:6261:7)
    at Hk (index-1uIJSkDh.js:6192:54)

Temporary Workaround

instead of import { ThemeContext } from "grommet"; (line 1)
use import { ThemeContext } from "grommet/contexts/ThemeContext";

Your Environment

  • Grommet version: 2.35.0
  • Browser Name and version: Chrome Version 121.0.6167.139
  • Operating System and version (desktop or mobile): MacOS
@sdosch sdosch changed the title Vite build produces error when using ThemeContext ViteJS build produces error when using ThemeContext Feb 8, 2024
@taysea taysea added the bug issue that does not match design or documentation and requires code changes to address label Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue that does not match design or documentation and requires code changes to address
Projects
None yet
Development

No branches or pull requests

2 participants