Looping through data by using map

I am looking into creating my own renderer for tables and treeview (material-ui/lab).
There is right now one problem: I cannot build my own structure by looping through the data. Instead of looping, it says “data.baseProperties is undefined”. But when debugging, the whole information of data.baseProperties is in fact available. Probably using the wrong export? Thanks!

[original thread by Seprech]


const MyArrayTester = ({ 
}: InputControlProps) => (
    <TableContainer component={Paper}>
      <Table aria-label="simple table">
            <TableCell align="right">Type</TableCell>
            <TableCell align="right">Description</TableCell>
            <TableCell align="right">Example</TableCell>
          {cells.map((row, index) => (
            <TableRow key={row.name}>
              <TableCell component="th" scope="row">
              onClick={(ev: any) => {//debugging
                var all = "";
                for(var prop in data) {
                  all+=prop + '\n';
              <TableCell align="right">{row.type}</TableCell>
              <TableCell align="right">{row.description}</TableCell>
              <TableCell align="right">{row.example}</TableCell>

export const myArrayTester = rankWith(1000, scopeEndsWith('baseProperties'));
export default withJsonFormsLayoutProps(MyArrayTester);

Hi @seprech(seprech), looks like you are using the wrong HOC. withJsonFormsLayoutProps doesn’t provide data as there is no data to show for a layout renderer. You probably want to use withJsonFormsControlProps or withJsonFormsArrayControlProps.


Hi Stefan, thanks for the fast reply! cells.map is wrong, I’ve used that to get no error and have in fact access to the data when doing the onclick function. data has the property baseProperties which is a array so normaly it should work with data.baseProperties.map(… but somehow I get the a typerror “data is undefined”. I’ve tried your recommendations but still ending in getting an error before even the loop gets started.


Found the solution: it is all about preventing an possible error therefore the map function needs to be called like data&& data.map(…

Great that you found a solution!