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

TypeError: name.toLowerCase is not a function in mode option #108

Closed
ThomasDuin opened this issue May 10, 2021 · 12 comments
Closed

TypeError: name.toLowerCase is not a function in mode option #108

ThomasDuin opened this issue May 10, 2021 · 12 comments

Comments

@ThomasDuin
Copy link

The documentation says you can also use an object as a configuration for prop mode. When I use the example ( {name: "javascript", json: true}) it says name.toLowerCase is not a function. Is this a bug regarding this package?

/** string|object. The mode to use. When not given, this will default to the first mode that was loaded.
It may be a string, which either simply names the mode or is a MIME type associated with the mode.
Alternatively, it may be an object containing configuration options for the mode,
with a name property that names the mode (for example {name: "javascript", json: true}). */
mode?: any;

meta.js:213 Uncaught (in promise) TypeError: name.toLowerCase is not a function
at Function.CodeMirror.findModeByName (meta.js:213)
at _callee$ (index.js:79)
at tryCatch (runtime.js:63)
at Generator.invoke [as _invoke] (runtime.js:293)
at Generator.next (runtime.js:118)
at asyncGeneratorStep (asyncToGenerator.js:3)
at _next (asyncToGenerator.js:25)
at asyncToGenerator.js:32
at new Promise ()
at asyncToGenerator.js:21

@jaywcjlove
Copy link
Member

@ThomasDuin Upgrade + @uiw/react-codemirror@3.0.7

@ThomasDuin
Copy link
Author

Thank you for responding so quickly and trying to get a fix out there, but I still seem to get the same error.

@jaywcjlove
Copy link
Member

@ThomasDuin Examples are welcome.

@ThomasDuin
Copy link
Author

@jaywcjlove
Copy link
Member

jaywcjlove commented May 10, 2021

@ThomasDuin

<CodeMirror
  value={code}
  options={{
    theme: "monokai",
    keyMap: "sublime",
-    mode: { name: "javascript", json: true }
+    mode: 'javascript'
  }}
/>

@ThomasDuin
Copy link
Author

The json property doesn't do anything?

@raquelhortab
Copy link

I'm trying to use the options prop but it does nothing, the only change I see is that the outer div in the DOM has options="[object Object]" so basically it seems to be passing the prop directly to the DOM element but not using it at all.

@jaywcjlove
Copy link
Member

jaywcjlove commented Feb 15, 2022

@raquelhortab

options parameter does not exist in v4+ version

@raquelhortab
Copy link

raquelhortab commented Feb 15, 2022

oh! and how are we suposed to use codemirror's configuration options? (this and this)

@jaywcjlove

@jaywcjlove
Copy link
Member

@raquelhortab Downgrade to version 3.0.

@raquelhortab
Copy link

@raquelhortab Downgrade to version 3.0.

oh... okay! Is there any way I can get the bundled version for v3? Just like you fix it up yesterday for v4? Or get the commands needed to generate it myself. I am sorry to be bothering, if that is an inconvenience I'll try to settle with v4 or find an alternative library. Thanks for the support!

@raquelhortab
Copy link

raquelhortab commented Feb 15, 2022

I think I got it, I'll leave it here in case someone needs it
https://unpkg.com/@uiw/react-codemirror@3.2.1/lib/index.js

Edit: sorry that's not really the bundled version

Edit 2: I tried adding the following npm scripts but it just generated a bunch of oversized js files named xxxxx.chunk.js

"bundle": "kkt build --bundle",
"bundle:min": "kkt build --bundle --mini --no-emptyDir",

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

3 participants