How to setup Material-UI for React with Typescript?

前端 未结 4 1322
夕颜
夕颜 2021-01-31 17:24

I\'ve run in some problems add Material UI to my React project, which is programmed with Typescript.

According to the tutorial, I start with adding the react-tab-event-p

4条回答
  •  悲哀的现实
    2021-01-31 17:38

    Your comment already pointed out the core problem. The typings are not up-to-date, or in other words: completely off.

    Long story short, it seems like the structure of material-ui has changed and everything is camelcase (instead of dashes) and in root, not the lib folder now.

    To fix this, open your material-ui/index.d.ts file and start changing everything from

    declare module 'material-ui/lib/text-field' {
    

    to

    declare module 'material-ui/TextField' {
    

    If unsure, check your node_modules/material-ui folder to see the file structure. The ambient module name must match the underlying file structure.

    This probably won't fix all your problems, but it could be a start.

提交回复
热议问题