Reputation: 198
I've been working with a lot of Material-UI components recently, and for the most part, they are pretty easy to import. I'm starting to find that the documentation on http://www.material-ui.com/ is not very good when it comes to showing where to import components from.
For example, to import the List component, one needs to import from material-ui/lib/lists/list. Is there a known dictionary with these component and import paths associated? It gets quite frustrating to not be able to import the necessary components, even though they do seem to follow a fairly common path, i.e., material-ui/lib/.
It doesn't look like the repo on GitHub contains the true paths to the components, so better documentation might be the answer.
Thanks!
Upvotes: 3
Views: 2956
Reputation: 3780
The example code in the docs is the very code that is run to create the examples. The imports shown there are the imports actually used by that code (for the version of Material-UI you are checking the docs for).
If an import isn't working, it is likely that either you're using a different version of Material-UI to that for which you are looking at the docs, or you have a typo in your import.
I had to import List using 'material-ui/lib/lists/list'
This confirms that your installed version of Material-UI is 0.15.0-alpha.2 or prior. We moved to the new directory structure in beta.1: https://github.com/callemall/material-ui/releases/tag/v0.15.0-beta.1, thanks to this PR: https://github.com/callemall/material-ui/pull/3749
Upvotes: 1