'Material Table Overwrite Toolbar Component

To override a button in the Toolbar component of react Material Table, I copied the official Material Table Toolbar component and pasted it unchanged into my project. Then I overwrote the Toolbar component as described in the documentation:

<MaterialTable 
          title={"Test"}
          columns={this.state.columns} 
          data={this.state.data}
          components={
            {Toolbar:props => (
            <div>
                <MTableToolbar {...props}/>
            </div>)}
          }
          icons={tableIcons}
          options=
          {{
              showEmptyDataSourceMessage: true, 
              maxBodyHeight: 500
          }} />

But now I always get the following error: "Cannot read properties of undefined (reading 'root')". I went through the code and found that the prop classes seems to be undefined. At another place in my project I did almost exactly the same (i.e. in Material Table I overwrote the Toolbar component etc.) and it doesn't throw me the said error. Do any of you have any idea where the error might be coming from. Thanks in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source