Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayField with nested SingleFieldList broken in version 3.6.0 #4916

Closed
sebitoelcheater opened this issue Jun 8, 2020 · 3 comments
Closed

Comments

@sebitoelcheater
Copy link

What you were expecting:
SingleFieldList to work properly inside ArrayField, as in version 3.5.5.

<ArrayField source="statements">
  <SingleFieldList>
    <ChipField source="name"/>
  </SingleFieldList>
</ArrayField>

What happened instead:
It throws

TypeError: Cannot read property 'map' of undefined

Steps to reproduce:
Visit list in any resource view with List component containing ArrayField with a nested SingleFieldList:

<ArrayField source="statements">
  <SingleFieldList>
    <ChipField source="name"/>
  </SingleFieldList>
</ArrayField>

Related code:

export const CompanyList = props => (
  <List {...props}>
    <Datagrid rowClick="edit">
      <ArrayField source="statements">
        <SingleFieldList>
          <ChipField source="name"/>
        </SingleFieldList>
      </ArrayField>
    </Datagrid>
  </List>
);

Other information:
This PR seems to be causing the error.

Environment

  • React-admin version: 3.6.0
  • Last version that did not exhibit the issue (if applicable): 3.5.5
  • React version: ^16.13.1
  • Browser: Chrome
  • Stack trace (in case of a JS error): TypeError: Cannot read property 'map' of undefined
@djhi
Copy link
Collaborator

djhi commented Jun 9, 2020

Fixed by #4918

@djhi djhi closed this as completed Jun 9, 2020
@AntoineAwaida
Copy link

AntoineAwaida commented Jun 11, 2020

Just had the same issue since I went on the 3.6.0 version, but with different error

Uncaught TypeError: Cannot read property 'map' of undefined
    at SingleFieldList (0.chunk.js:138755)

My list component:

export const AbonnementList = (props) => (
  <List {...props} filters={<FullFilter />}>
    <Datagrid rowClick='edit'>
      <TextField source='id' />
      <TextField source='name' />
      <TextField source='price' />
      <TextField label='Période de facturation' source='pricePeriod' />
      <TextField label="Période d'octroi des crédits" source='offeredPeriod' />

      <ArrayField source='descriptions'>
        <SingleFieldList linkType={false}>
          <TextField source='description'></TextField>
        </SingleFieldList>
      </ArrayField>
      <EditButton />
    </Datagrid>
  </List>
);

And of course, the fix proposed in the PR didn't work.

What is strange though is that rolling back to 3.5.3 didn't work as well. However this happened only due to the fact I ran npm install this morning... (I put my code on a server for deployment, the issue occured due to level up with npm install, then running npm install locally leaded to this error, and now impossible to get rid of it).

@fzaninotto
Copy link
Member

@DeciusAntiochus I can't reproduce the problem you describe. Please provide a CodeSandbox reproducing your error, and open a new issue with its link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants