I want to add a collapse effect to my list when I click my edit button so a body appears below my list element for input fields to edit the object. I am using react-bootstrap for the Collapse and ant-d for list.
Here is my List:
<List
dataSource={this.state.data}
renderItem={item => (
<List.Item key={item.id} actions = {
[
<Button type="primary" onClick={() => this.setState({ open: !open })}
aria-controls="example-fade-text"
aria-expanded={open} >
Edit
</Button>,
<Button type="primary">
Add to cart
</Button>
]
}>
<List.Item.Meta
avatar={<Avatar src={icon} size={64} />}
title={item.name}
description={item.description}
/>
<div>Content</div>
<Collapse in={this.state.open}>
<div id="example-collapse-text">
here's some text
</div>
</Collapse>
</List.Item>
)}
>
This is the error I receive:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of Context.Consumer
(I did not make this file, most likely auto generated by react).
29 | axios.get(DataUrl).then(
30 | res => {
31 | const apiData = res.data;
> 32 | this.setState({data: apiData})
| ^ 33 | }
34 | )
35 | }
These are the contents of my state:
state = {
data: [],
loading: false,
hasMore: true,
open: false,
}
and I have const { open } = this.state.open
inside my render function.
Related notes: I have the entire thing wrapped around InfiniteScroll ,but that shouldn't affect it, (I think).
My fetchData axios call works perfectly fine when I do not have Collapse used so I don't know why it's causing this issue.