Replies: 5 comments
-
Docs are indeed broken. Without this issue I would never have figured out that the expanded property takes an array. Note that you can get around this issue by using the renderHeader property found in the docs: https://docs.nativebase.io/Components.html#accordion-def-headref Even using the example renderHeader will work. From the docs: import React, { Component } from "react";
import { Container, Header, Content, Icon, Accordion, Text, View } from "native-base";
const dataArray = [
{ title: "First Element", content: "Lorem ipsum dolor sit amet" },
{ title: "Second Element", content: "Lorem ipsum dolor sit amet" },
{ title: "Third Element", content: "Lorem ipsum dolor sit amet" }
];
export default class AccordionCustomHeaderContent extends Component {
_renderHeader(item, expanded) {
return (
<View style={{
flexDirection: "row",
padding: 10,
justifyContent: "space-between",
alignItems: "center" ,
backgroundColor: "#A9DAD6" }}>
<Text style={{ fontWeight: "600" }}>
{" "}{item.title}
</Text>
{expanded
? <Icon style={{ fontSize: 18 }} name="remove-circle" />
: <Icon style={{ fontSize: 18 }} name="add-circle" />}
</View>
);
}
_renderContent(item) {
return (
<Text
style={{
backgroundColor: "#e3f1f1",
padding: 10,
fontStyle: "italic",
}}
>
{item.content}
</Text>
);
}
render() {
return (
<Container>
<Header />
<Content padder style={{ backgroundColor: "white" }}>
<Accordion
dataArray={dataArray}
animation={true}
expanded={true}
renderHeader={this._renderHeader}
renderContent={this._renderContent}
/>
</Content>
</Container>
);
}
}
<br/> |
Beta Was this translation helpful? Give feedback.
-
@mikealeonetti thanks for a temporary workaround! It worked for me! |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
Accordion Component is not fully supported yet. We're working on API and accessibility of this component. Moving this issue to the discussion. |
Beta Was this translation helpful? Give feedback.
-
I have gone through these following points
Issue Description
node, npm, react-native, react and native-base version, expo version if used, xcode version
Expected behaviour
Accordion title is rendered.
Actual behaviour
Accordion title is not rendered.
Steps to reproduce
Expo.io demo snack.
Accordion
component.Is the bug present in both iOS and Android or in any one of them?
The bug is present on both platforms.
Any other additional info which would help us debug the issue quicker.
The component docs are also broken: the
expanded
prop expects an array, not a number. So, maybe it's the problem with the docs and the property is expected to be called something else instead oftitle
.Screenshots
Beta Was this translation helpful? Give feedback.
All reactions