langleyfoxall / langleyfoxall/react-dynamic-data-table

Do not stringify object rows, skip over them instead

Open
#30 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
12
Forks
16
PR merge metrics
No merged PRs in 30d

Description

Currently within the source object/array get stringified. I propose mapping these to null and then filtering columns in render.

Original:

    render() {
        const { row, fields } = this.props;

        return (
            <tr onClick={() => this.handleOnClick(row)}>
                { this.renderCheckboxCell(row.id) }
                { fields.map(field => this.renderCell(field, row)) }
                { this.renderButtons(row) }
            </tr>
        );
    }

    // ...

    renderCell(field, row) {
        let value = row[field.name];

        value = this.props.dataItemManipulator(field.name, value);

        if (typeof value === 'object' || typeof value === 'array') {
            value = JSON.stringify(value);
        }

        return (
            <td key={`${row.id}_${field.name}`}>{ value }</td>
        );
    }

New:

    render() {
        const { row, fields } = this.props;

        return (
            <tr onClick={() => this.handleOnClick(row)}>
                { this.renderCheckboxCell(row.id) }
                { fields.map(field => this.renderCell(field, row)).filter(field => field) }
                { this.renderButtons(row) }
            </tr>
        );
    }

    // ...

    renderCell(field, row) {
        let value = row[field.name];

        value = this.props.dataItemManipulator(field.name, value);

        if (typeof value === 'object' || typeof value === 'array') {
            return null;
        }

        return (
            <td key={`${row.id}_${field.name}`}>{ value }</td>
        );
    }

Thoughts?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Components/DataRow.jsx around lines 53–65 and read how render and renderCell currently handle field values. Verify the intended behavior for object and array values, then confirm that ordinary scalar cells still render and object rows are omitted without stringification. No test file is mentioned, so validate the rendered table behavior using the repository’s available checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.