langleyfoxall / langleyfoxall/react-dynamic-data-table

Allow valid react elements to be used in data manipulator

Open
#41 3 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

I want to add a symbol (such as an up/downward facing arrow) within a single column. I'd like to be able to do this within the dataItemManipulator function as I am only changing a single column.

If we want to keep dataItemManipulator clear of elements, then we should look into implementing a low level cellRenderer on DataRow.

Currently the object/array check in renderCell causes a circular JSON.stringify error when attempting to pass a React element into it (as a React element is an object, verified by $$symbol).

Here's the current expression:

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

Perhaps this could be:

if (!React.isValidElement(value)) {
    value = JSON.stringify(value);
}

Or:

import Util from '@ninetynine/util';

// ...

if (Util.isObject(value) || Util.isArray(value)) {
    value = JSON.stringify(value);
}

It's worth noting that currently null gets stringified as in JavaScript null is an object.

Thoughts?

cc @NilesB @DivineOmega @wheatleyjj

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 at the renderCell logic and trace how values from dataItemManipulator reach DataRow. Determine whether valid React elements should be preserved there or whether DataRow needs a low-level cellRenderer, while keeping ordinary objects and arrays handled appropriately. Done means a React element can render in a single column without triggering circular JSON.stringify errors.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.