DEV Community

Discussion on: React Form using Formik, Material-UI and Yup.

Collapse
 
bishbashbosh123 profile image
James Robinson

Hey, this is a great tutorial. Many thanks!

With regard to the styling bit, I'm having trouble getting the styles func/object in InputForm/index.js to have any effect. It doesn't seem to have any effect in your code sandbox demo either. This is my first foray with CSS in JS outside of React Native.

Your styles func takes in a theme argument, which lead me to think I need to wrap everything at a higher level with a <MuiThemeProvider />, but I haven't worked out what to give it for it's mandatory 'theme' prop yet. Any advice on this would be great!

Collapse
 
bishbashbosh123 profile image
James Robinson

Predictably, about 10 seconds after posting that comment I found out what the problem was. Looking at the withStyles() docs, I can see that this:

const classes = this.props;

should be...

const {classes} = this.props;

It did seem strange at the time that withStyles would replace all props to the component, rather than just add to them.

Collapse
 
finallynero profile image
Nero Adaware

withStyles will not replace all the props to that component, it should just add to them.