question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

display array with arrayField or other

See original GitHub issue

Hello, I want to display a list of items that are stored in a array ([1,3,4,5,7…]) capture d ecran 2018-10-03 a 15 47 46 With ArrayField I can’t display the elements as I want because it expects an object array when I have a simple array. How to display the elements stored in a array ? Currently I am creating my own field for this :

const TagsFieldInstitutes = ({ record }) => (
  <div>
    {record.institutes.map(item => (
      <span key={item} className="chip">
        {item}
      </span>
    ))}
  </div>
);

But I think there is a better way. Thanks you for your help !

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

42reactions
dantmancommented, Feb 28, 2019

I cannot comprehend why this has been essentially wontfixed. There is nothing at all strange about an API returning an array of strings like ['a', 'b', 'c']. And it’s ridiculous to expect the API to be rewritten to return [{label: 'a'}, {label: 'b'}, {label: 'c'}]. That changes the API response that other clients uses from a sensible response to a nonsensical one.

30reactions
fzaninottocommented, Dec 26, 2018

@afilp as explained in the documentation:

If you need to render a collection in a custom way, it’s often simpler to write your own component:

const TagsField = ({ record }) => (
    <ul>
        {record.tags.map(item => (
            <li key={item.name}>{item.name}</li>
        ))}
    </ul>
)
TagsField.defaultProps = { addLabel: true };

We won’t add a new field to replace a one liner in userland.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to display Django array data - Stack Overflow
How to display Django array data ... I have inserted some data into the models array field. ... I want to view my...
Read more >
Is it possible to display the ArrayField as a list of elements ...
My model contains a field like this: from django.contrib.postgres.fields import ArrayField text_list = ArrayField(models.
Read more >
How to display a table refering to an array field from ... - Wix.com
I have a collection of data with an array field. I'm trying to display the content from the array field in a table...
Read more >
The ArrayField Component - React-admin - Marmelab
Display a collection using <Field> child components. Ideal for embedded arrays of objects, e.g. tags and backlinks in the following post object: { ......
Read more >
Display array fields - IBM
You can expand such a field to display the values in the array, ... In an unexpanded array field or in an array...
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