Home > Mobile >  npm @material-ui/core Button and TexField not working
npm @material-ui/core Button and TexField not working

Time:09-17

I am building a React application and I wanted to use the material-ui framework.

I build a component with a textfield and a button but I can`t click the textfield neither the button their blocked.

Here is the component code:

import React, { Component } from 'react';
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';


class Descarcare extends React.Component {
constructor(props) {
  super(props);
  this.state = {  };
 
}



render() {
   return(
<div>
<h1>Descarcare</h1>

<TextField id="standard-required" label="ID" InputProps={{
        readOnly: false,
      }}/>
<Button variant="contained" color="primary">
Trimite
</Button>
</div>
   );
}

 }

export default Descarcare;

The component appears in the browser but I can`t press the button it is blocked and so is the input field. I can not write anything in it. Can please someone help me ? Thanks in advance

CodePudding user response:

You have to provide the onClick and onChange functions respectively.

CodePudding user response:

It might be related to your other configs, You could have a reference to this example:

Edit Material demo (forked)

CodePudding user response:

In React you got to control inputs see here as for the material-ui library buttons default to disable if no onClick is provided (if I recall correctly) and text fields need value and onChange to react! hope it is helpfull

  • Related