Passing props to MUI styles

Deleted the old answer, because it’s no reason for existence. Here’s what you want: import React from ‘react’; import { makeStyles } from ‘@material-ui/core’; const useStyles = makeStyles({ firstStyle: { backgroundColor: props => props.backgroundColor, }, secondStyle: { color: props => props.color, }, }); const MyComponent = ({children, …props}) =>{ const { firstStyle, secondStyle } = … Read more

How to change the border color of MUI TextField

<CssTextField label=”Username” className=”username” name=”username” onChange={this.onChange} type=”text” autoComplete=”current-password” margin=”normal” inputProps={{ style: { fontFamily: ‘nunito’, color: ‘white’ } }} /> //declare the const and add the material UI style const CssTextField = withStyles({ root: { ‘& label.Mui-focused’: { color: ‘white’, }, ‘& .MuiInput-underline:after’: { borderBottomColor: ‘yellow’, }, ‘& .MuiOutlinedInput-root’: { ‘& fieldset’: { borderColor: ‘white’, }, ‘&:hover … Read more

How to get the TextField value when enter key is pressed in React?

Use onKeyDown event, and inside that check the key code of the key pressed by user. Key code of Enter key is 13, check the code and put the logic there. Check this example: class CartridgeShell extends React.Component { constructor(props) { super(props); this.state = {value:”} this.handleChange = this.handleChange.bind(this); this.keyPress = this.keyPress.bind(this); } handleChange(e) { this.setState({ … Read more

material-ui Drawer – findDOMNode is deprecated in StrictMode

According to Material-ui changelog, it should be solve in V5, which is still in alpha. It seems that at least in some cases this issue cause by createMuiTheme. You can solve this issue by using the experimental (unstable) theme creator If you want to get the experimental theme creator instead of removing React.StrictMode, you can … Read more

Using async/await inside a React functional component

You will have to make sure two things useEffect is similar to componentDidMount and componentDidUpdate, so if you use setState here then you need to restrict the code execution at some point when used as componentDidUpdate as shown below: function Dashboard() { const [token, setToken] = useState(”); useEffect(() => { // React advises to declare … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)