Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n.spacing is not a function #18

Closed
Falkovic1993 opened this issue Jul 4, 2019 · 7 comments
Closed

n.spacing is not a function #18

Falkovic1993 opened this issue Jul 4, 2019 · 7 comments

Comments

@Falkovic1993
Copy link

Hey Alex,

Getting this error when trying to add the component to my site.

Warning: Material-UI: the `styles` argument provided is invalid.
You are providing a function without a theme in the context.
One of the parent elements needs to use a ThemeProvider.

I'm just importing it: import MuiPhoneNumber from 'material-ui-phone-number';

And then using it: <MuiPhoneNumber defaultCountry="us" onChange={this.handleChange} />

Seems like an issue with the Theme and it can't find the spacing? You have any ideas about how to fix this?

@hassanabbas9
Copy link

same issue, + 1

@Falkovic1993
Copy link
Author

This got fixed by updating to the new version of material-UI v4. The spacing has changed in that version which was the reason it broke.

When clicking the flag tho, it's really slow to open up the list of countries. What could that be?

@alexplumb
Copy link
Owner

Thanks for the update, @Falkovic1993. Yes, @material-ui/core@4 is required for version 2 of this package - if you are currently on @material-ui/core@3, please downgrade to version 1.

If you're concerned about performance, please either include the specific countries you want in the onlyCountries parameter, or use a native select by using the native flag. I plan on adding react-window support soon in order to resolve the performance issues that some people have.

@vinaydate
Copy link

vinaydate commented Jul 9, 2019

Still having the issue.

"@material-ui/core": "^4.1.3",
"material-ui-phone-number": "^2.0.0",
"@material-ui/styles": "^4.1.2", (it is actually 4.2.0)
I have tried with exact 4.1.2 version of styles as well, with same outcome

@alexplumb
Copy link
Owner

@vinaydate Can you confirm that you're using the ThemeProvider component in your code? This library does make use of the spacing method of the theme provider, specifically the @material-ui/styles/ThemeProvider component.

@alexplumb
Copy link
Owner

Actually, you know what, I just released an update (2.0.1) that removes the reliance on the theme provider. Please upgrade and let me know if that fixes it for you.

@vinaydate
Copy link

vinaydate commented Jul 20, 2019 via email

justdvl referenced this issue in justdvl/material-ui-phone-number-2 May 18, 2022
…el-loader-8.2.4

Bump babel-loader from 8.2.2 to 8.2.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants