Failed prop type: Invalid prop `children` supplied to `ForwardRef(TableCell)`, expected a ReactNode.

See original GitHub issue

Hey, i have a strange problem. this error (in title) appears on component second render after set state.

Which code should i show you to clear my question?

` import React, { useEffect, useState } from ‘react’; import { connect } from ‘react-redux’; import { Grid, MuiThemeProvider } from ‘@material-ui/core’; import { createMuiTheme } from ‘@material-ui/core/styles’; import MaterialTable from “material-table”; import { Button, Breadcrumb, BreadcrumbItem, Card, CardBody, CardHeader, Col, Row } from ‘reactstrap’; import commands from ‘…/…/…/actions/dataTable/commands’;

function Marketplaces (props) { const {marketplaces, getMarketPlaces} = props; const [multiselection, setMultiselection] = useState(false);

const tableRef = React.createRef();


useEffect(() => {
    getMarketPlaces();
}, []);

const handleEditClick = () => {
  setMultiselection(!multiselection);
};

const columns = marketplaces && [
    ...Object.keys(marketplaces[0]),
].map(col => ({
    title: col.toUpperCase(),
    field:col,
  }));

  let direction = 'ltr';
  // direction = 'rtl';
  
  const theme = createMuiTheme({
    direction: direction,
    palette: {
      type: 'light'
    }
  });
return (
    !!marketplaces ? 
    (<MuiThemeProvider theme={theme}>
      <div style={{ maxWidth: '100%', direction }}>
        <Grid container>
          <Grid item xs={12}>
            <MaterialTable
              tableRef={tableRef}
              columns={columns}
              data={marketplaces}
              editable={{
                onRowAdd: newData =>
                  new Promise(resolve => {
                    setTimeout(() => {
                    //   resolve();
                    //   const data = [...state.data];
                    //   data.push(newData);
                    //   setState({ ...state, data });
                    }, 600);
                  }),
                onRowUpdate: (newData, oldData) =>
                  new Promise(resolve => {
                    setTimeout(() => {
                      resolve();
                    //   const data = [...data];
                    //   data[data.indexOf(oldData)] = newData;
                    //   setState({ ...state, data });
                    }, 600);
                  }),
                onRowDelete: oldData =>
                  new Promise(resolve => {
                    setTimeout(() => {
                    //   resolve();
                    //   const data = [...state.data];
                    //   data.splice(data.indexOf(oldData), 1);
                    //   setState({ ...state, data });
                    }, 600);
                  }),
              }}
              actions={[
                {
                  icon: 'list_alt',
                  tooltip: 'Select multiple',
                  isFreeAction: true,
                  onClick: (event, rowData) => {
                    handleEditClick();
                  }
                }
              ]}
              title="Demo Title"
              options={{
                selection: multiselection,
                filtering: true,
                exportButton: true,
              }}
              onSearchChange={(e) => console.log("search changed: " + e)}
              onColumnDragged={(oldPos, newPos) => console.log("Dropped column from " + oldPos + " to position " + newPos)}
            />
          </Grid>
        </Grid>
      </div>
    </MuiThemeProvider>)
  :
  (<div/>)
);

}

const mapState = state => { const { marketplaces } = state.tables; return { marketplaces }; }

const mapDispatch = dispatch => ({ getMarketPlaces: () => { dispatch(commands.getMarketplaces())}, });

export default connect(mapState, mapDispatch)(Marketplaces); `

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13

github_iconTop GitHub Comments

20reactions
masbaehrcommented, Jan 30, 2020

Hi i’ve noticed in my case the issue was that the tableData had boolean field values, which caused the error. This can be avoided by doing this or setting the render parameter for the columns. You will quickly see what column is causing the problem, when it is being rendered as empty!

for(var tdata of dataArray){
      for(var tdatakey of Object.keys(tdata)){
         
        if(tdata[tdatakey] === true){
          tdata[tdatakey] = "true";
        }
        if(tdata[tdatakey] === false){
          tdata[tdatakey] = "false";
        }
      }
    }

15reactions
pan1982commented, Sep 24, 2019

Found solution. So, if your data have ‘id’ key, please rename it or remove it, cos MT doesn’t like this field in data. Dont know why

Objects are not valid as a React child (found: object with keys {id}).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: Failed prop type: Invalid prop `children` supplied to ...
I'm trying to render certain inputs if a variable is true but when the component render displays the warning Warning: Failed prop type:...
Read more >
Invalid prop `children` supplied to `ForwardRef(TableCell ...
js:1375 Warning : Failed prop type: Invalid prop `children` supplied to `ForwardRef(TableCell)`, expected a ReactNode. in ForwardRef(TableCell) ( ...
Read more >
Warning: Failed prop type: Invalid prop `children ... - Medium
Warning: Failed prop type: Invalid prop `children` supplied to `ForwardRef(Typography)`, expected a ReactNode. */<Typography key={item.id}>
Read more >
[Solved]-Failed prop type: Invalid prop `children` supplied to ...
Coding example for the question Failed prop type: Invalid prop `children` supplied to `ForwardRef(Select)`, expected a ReactNode-Reactjs.
Read more >
Invalid prop children warning with Button - Telerik Forums
Warning: Failed prop type: Invalid prop `children` supplied to `Button`. in Button (created by App) in App H...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found