Answer a question

Description

I am trying to use Material-UI's theme.spacing function in a React application but the spacing function is not recognized.

The Javascript error message is: TypeError: theme.spacing is not a function

I am unsure if this is a bug or I have something wrong with the frameworks versions being installed.


Context

  • Here's the Github issue raised to address this problem.
  • Here's the repo with the offending code. The error is caught in the src\pages\index.js file, line 16: paddingTop: theme.spacing(20)
  • Here's the sandboxed repo running where you can actually see the error message.

These are the frameworks versions being installed, according to the package-lock.json file:

  • Material-UI: v3.9.2
  • React: v16.8.1
  • Chrome: v72.0.3626.96
  • TypeScript: None
  • create-react-app: v3.2.2

Answers

Well, it turns out this is a bug after all, caused by request #14099.

A fix is on the way now, so I am closing this question.

Logo

React社区为您提供最前沿的新闻资讯和知识内容

更多推荐