Invalid prop `actions[0]` supplied to `MaterialTable` and fontSize='small'
See original GitHub issueDescribe the bug
Warning: Failed prop type: Invalid prop actions[0]
supplied to MaterialTable
.
Can’t pass fontSize props when using string icon
To Reproduce Steps to reproduce the behavior:
- Add actions to Material Table component
Example :
actions={[ { icon: 'create', tooltip: 'Add', onClick: (event, rowData) => { //Do stuff } } ]
- Instead of a string, pass an icon component directly as the icon props
import Create from ‘@material-ui/icons/Create’;
Example :
actions={[ { icon: Create, tooltip: 'Add', onClick: (event, rowData) => { //Do stuff } } ]
- See error in console
- Additionnaly, because of this in m-table-action.js
{typeof action.icon === "string" ? ( <Icon {...action.iconProps} fontSize="small">{action.icon}</Icon> ) : ( <action.icon {...action.iconProps} disabled={action.disabled} /> ) }
We can’t change the fontSize props if the icon is a string, for example if I seticonProps: { fontSize: 'default' }
My props will be overriden by the hardcoded one (fontSize=“small”).
Expected behavior We shouldn’t get this warning. You should probably remove this fontSize props to let users customize the size.
Desktop (please complete the following information):
- Chrome (didn’t test on other platforms)
- Version 1.39.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:18 (2 by maintainers)
Top Results From Across the Web
Invalid prop `data` supplied to `MaterialTable`, expected one ...
I am working in a jhipster application, with data coming from postgress sql. The api is http://localhost:8080/api/agreements and I am trying to ...
Read more >material-table/Lobby - Gitter
Hi guys, how do I put the material-table on always edit mode. ... **Warning: Failed prop type: Invalid prop `actions[0]` supplied to `MaterialTable`....
Read more >Warning: Failed prop type: Invalid prop `actions[0]` supplied to ...
Describe the bug. The following appears in the console: Warning: Failed prop type: Invalid prop actions[0] supplied to MaterialTable .
Read more >material-table
material-table. React data table component that is based on material-ui. Get Started. GitHub stars. Actions. You can add one or multiple row based...
Read more >Using material-table in React to build feature-rich data tables
To render a table with material-table, you have to supply the ... We can easily add actions by passing an actions array prop...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@IdkMan2 @mbrn FYI–
I FINALLY FOUND A FIX!
I was previously supplying my actions as objects like this:
Changing each action to a
function
resolved this for me!!!THE FIX:
It clears the warning but it doesn’t work with isFreeAction: true unfortunately.