I'm very new to ReactJS but from what I gather the following code should work and it doesn't.
I've created a new ReactJS project using the npm command create-react-app.
In my project folder I've installed Google's material ui with npm install --save material-ui@next.
I'm getting various errors depending on what I'm trying to import from 'material-ui'.
import Card from 'material-ui/Card'
I'm using VS Code as my editor and if I hit F12 on 'material-ui/Card' it shows me that Card is the default export, and the import above works.
import {Card} from 'material-ui'
If I hit F12 on 'material-ui' it shows me that Card is a named export, and the import above works.
Where I run in to trouble is when I try to import other things. For instance:
import {Card, CardText} from 'material-ui'
Card imports fine, but when I try to use
React.createElement: type is invalid -- expected a string (for built-in
components) or a class/function (for composite components) but got:
undefined. You likely forgot to export your component from the file it's
defined in.
However, as far as I can tell they are both being exported the same exact way.
declare module "material-ui" {
export import Card = __MaterialUI.Card.Card;
export import CardText = __MaterialUI.Card.CardText;
}
and digging even further:
export interface CardTextProps {
actAsExpander?: boolean;
color?: string;
expandable?: boolean;
style?: React.CSSProperties;
className?: string;
}
export class CardText extends React.Component {
}
Other imports also fail for me when they look like they should work:
import getMuiTheme from 'material-ui/styles/getMuiTheme'
Module not found: Can't resolve 'material-ui/styles/getMuiTheme'
But as far as I can tell, it's there...