Git Product home page Git Product logo

Comments (15)

0livare avatar 0livare commented on July 17, 2024 18

Because there's not really an "answer" on this thread, I wanted to supply the one that worked for me:

import * as classnames from 'classnames'

from classnames.

AndyOGo avatar AndyOGo commented on July 17, 2024 15

@ramarivera

I'm just curious, may I ask you to try this:

import classNames from 'classNames';

If that works, it is related to another bug I issued months ago:
#82 (comment)

from classnames.

AndyOGo avatar AndyOGo commented on July 17, 2024 12

@ramarivera
@dcousens

Sure I can help out.
@ramarivera your syntax is wrong, make sure to read the docs and understand how import works.
Especially default imports as described in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Importing_defaults

Correct code would be in your case:

import classNames from 'classnames'

from classnames.

mikestead avatar mikestead commented on July 17, 2024 6

@ramarivera Did you install the latest typings? npm install @types/classnames --save-dev

from classnames.

ramarivera avatar ramarivera commented on July 17, 2024 5

I tried that, but Typescript compiler says
Module '"classnames"' has no default export.

Just tried it again but got same results :/
(Thanks for the speedy reply!)

from classnames.

ramarivera avatar ramarivera commented on July 17, 2024 1

I can´t be sure of which of all the things i tried yesterday was, but something fixed it and now it's getting bundled correctly. Again, thanks for the quick replies and sorry for "wasting" your time 👍

from classnames.

shawfire avatar shawfire commented on July 17, 2024 1

I'm using typescript with React and this works for me:

npm i -D @types/classnames
import classNames from 'classnames';

from classnames.

dcousens avatar dcousens commented on July 17, 2024

I'm not familiar with webpack to this degree, maybe @AndyOGo could help

from classnames.

AndyOGo avatar AndyOGo commented on July 17, 2024

That's strange, I mean I use Babel, but that is really weird...

from classnames.

AndyOGo avatar AndyOGo commented on July 17, 2024

found microsoft/TypeScript#3337

from classnames.

ramarivera avatar ramarivera commented on July 17, 2024

I tried changing the syntax to what that thread provides, to no avail. I also changed my typescript loader from awesome-typescript-loader to ts-loader as suggested but it doesnt work either :(

from classnames.

ramarivera avatar ramarivera commented on July 17, 2024

Nope :( it says that no module with that name can be found

from classnames.

AndyOGo avatar AndyOGo commented on July 17, 2024

If the above does not fix it, I found this issue:
Importing commonJS modules with es6 imports

from classnames.

havivi avatar havivi commented on July 17, 2024

Thx @zposten !!! import * as classnames from 'classnames' works for me too.

from classnames.

jcousins-ynap avatar jcousins-ynap commented on July 17, 2024

Whilst this gets rid of the original error I now get:

classnames__WEBPACK_IMPORTED_MODULE_3__ is not a function

TypeError: classnames__WEBPACK_IMPORTED_MODULE_3__ is not a function
    at MyComponent (http://localhost:9009/main.6dc20d2f7c98431509a6.bundle.js:353:740)
    at renderWithHooks (http://localhost:9009/vendors~main.6dc20d2f7c98431509a6.bundle.js:48679:18)
    at mountIndeterminateComponent (http://localhost:9009/vendors~main.6dc20d2f7c98431509a6.bundle.js:50761:13)
    at beginWork (http://localhost:9009/vendors~main.6dc20d2f7c98431509a6.bundle.js:51366:16)
    at performUnitOfWork (http://localhost:9009/vendors~main.6dc20d2f7c98431509a6.bundle.js:55053:12)
    at workLoop (http://localhost:9009/vendors~main.6dc20d2f7c98431509a6.bundle.js:55093:24)
    at renderRoot (http://localhost:9009/vendors~main.6dc20d2f7c98431509a6.bundle.js:55176:7)
    at performWorkOnRoot (http://localhost:9009/vendors~main.6dc20d2f7c98431509a6.bundle.js:56083:7)
    at performWork (http://localhost:9009/vendors~main.6dc20d2f7c98431509a6.bundle.js:55995:7)
    at performSyncWork (http://localhost:9009/vendors~main.6dc20d2f7c98431509a6.bundle.js:55969:3)

Inspecting the imported module object I don't see any usable functions:

{
  Symbol(Symbol.toStringTag): "Module",
  __esModule: true,
  __proto__: Object
}

from classnames.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.