Comments (15)
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.
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.
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.
@ramarivera Did you install the latest typings? npm install @types/classnames --save-dev
from classnames.
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.
I'm using typescript with React and this works for me:
npm i -D @types/classnames
import classNames from 'classnames';
from classnames.
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.
I'm not familiar with webpack to this degree, maybe @AndyOGo could help
from classnames.
That's strange, I mean I use Babel, but that is really weird...
from classnames.
found microsoft/TypeScript#3337
from classnames.
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.
Nope :( it says that no module with that name can be found
from classnames.
If the above does not fix it, I found this issue:
Importing commonJS modules with es6 imports
from classnames.
Thx @zposten !!! import * as classnames from 'classnames' works for me too.
from classnames.
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)
- why not using one build tool for publish the npm package? HOT 2
- Incomplete type signature for classnames/bind HOT 2
- Advanced typing for classnames/bind HOT 4
- Explain to me about "cx" HOT 1
- Getting error says 'this' context of type 'void' is not assignable HOT 4
- [Question] When I used Object's value to computed key, what happened? HOT 2
- SyntaxError: Unexpected end of script (Mobile Safari) HOT 5
- When no classes are selected, classNames should return null HOT 5
- Vulnerable dependencies (indirect security issues) HOT 1
- How to erase or replace the properties of the conditional class from external component? HOT 1
- why number can be a className HOT 1
- Can we add exports field for this package? HOT 4
- Need a maintainer? HOT 7
- Preparing for version 3.0 HOT 9
- Should we support CommonJS for 3.0? HOT 5
- No default export (v2.5.1) HOT 5
- Import from 'classnames' broken since v2.5.0 HOT 5
- Please use GitHub Releases HOT 6
- Unable to do v2 releases HOT 2
- Feature Request: Enhanced Responsive Classnames Support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from classnames.