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

Change CollapseHeader text if isCollapse is True #6

Closed
Base29 opened this issue Sep 1, 2018 · 5 comments
Closed

Change CollapseHeader text if isCollapse is True #6

Base29 opened this issue Sep 1, 2018 · 5 comments
Labels
question Further information is requested

Comments

@Base29
Copy link

Base29 commented Sep 1, 2018

Hello Guys ... I want to change the text within the when toggled .. here is my code

<Collapse
                        onToggle={(isCollapsed) => {
                            console.log(isCollapsed);
                            if (isCollapsed) {
                                this.setState({collapseHeaderText: 'Hide Order Detail'})
                            }
                        }}>
                    >
                        <CollapseHeader>
                            <View>
                                <Text style={myOrdersStyles.orderItemDetailsHeaderText}>{this.state.collapseHeaderText}</Text>
                            </View>
                        </CollapseHeader>
                        <CollapseBody>
                            {this.renderOrderItemDetails(orders)}
                        </CollapseBody>
                    </Collapse>

there is a state collapseHeaderText with a default value 'View Order Detail"

@Base29 Base29 changed the title Change CollapseHeader text if isCollapse is false Change CollapseHeader text if isCollapse is True Sep 1, 2018
@marouanekadiri
Copy link
Owner

Hi @Base29 ,
Can you describe what happens when you use this code?

@Base29
Copy link
Author

Base29 commented Sep 1, 2018

My goal was to change the text within the when the toggled ... When toggled the isCollapse turn to true ... I have a state that holds the initial text for 'View Order Detail' and when isCollapse is = true then it should change to 'Hide Order Detail' ... I want to know is there a function which change

@Base29
Copy link
Author

Base29 commented Sep 1, 2018

here is the code in paste bin ... https://pastebin.com/hkrXyHi3 the above mentioned code is on line 369

@Base29
Copy link
Author

Base29 commented Sep 1, 2018

So any way to change the when isCollapse = true ?

@marouanekadiri
Copy link
Owner

marouanekadiri commented Sep 2, 2018

You need only to manage the Collapse state yourself by providing its current state ( toggled or not)

<Collapse
    isCollapsed={this.state.toggled}
    onToggle={(isCollapsed) => {
        console.log(isCollapsed);
        if (isCollapsed) {
            this.setState({collapseHeaderText: 'Hide Order Detail', toggled: true})
        } else  {
            this.setState({toggled: false});
        }
    }}>
    >
    <CollapseHeader>
        <View>
            <Text style={myOrdersStyles.orderItemDetailsHeaderText}>{this.state.collapseHeaderText}</Text>
        </View>
    </CollapseHeader>
    <CollapseBody>
        {this.renderOrderItemDetails(orders)}
    </CollapseBody>
</Collapse>

@marouanekadiri marouanekadiri added the question Further information is requested label Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants