I've been diving into React and Material UI to enhance my web development skills.
While working on a web form, I encountered an issue where Chrome autofills the text fields with previous data and changes the background color to yellow upon page load. How can I prevent this and keep it white?
In traditional CSS, I would typically include the following code:
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0 1000px white inset;
}
However, without a dedicated style sheet, incorporating this is proving challenging.
Here's what I have tried so far:
const MyAwesomeReactComponent = React.createClass({
const containerStyle =
{
/* input:-webkit-autofill {
-webkit-box-shadow: 0 0 0 1000px white inset;
} */
};
return (
<div style={containerStyle}>
<form action="/login" method="post" autocomplete ="off">
<div>
<TextField hintText="Email Field" floatingLabelText="Email" underlineFocusStyle={{borderColor: Colors.amber900}} />
</div>
<div>
<TextField hintText="Password Field" floatingLabelText="Password" type="password" />
</div>
<div>
<RaisedButton label="Submit" primary={true}/>
</div>
</form>
});
module.exports = MyAwesomeReactComponent;
I'm encountering a Syntax error while handling the input-webkit-autofill
code during parsing.