Skip to content

Timeline doesn't update when adding custom components dynamically #180

Open
@PedroSilva8

Description

@PedroSilva8

Describe the bug
When changing custom content dynamically the timeline doesn't updating causing the new content not to show

Example Code

Update Code
this.setState({timelineItems: val});

Render Code

                            <Chrono mode='VERTICAL_ALTERNATING' hideControls={true} allowDynamicUpdate={true} scrollable={false} useReadMore={false} theme={{
                                primary: ThemeHandler.Secondary(),
                                secondary: ThemeHandler.Content('surf'),
                                titleColor: ThemeHandler.Font(),
                                cardBgColor: ThemeHandler.Content(),
                                textColor: ThemeHandler.Font(),
                                cardForeColor: ThemeHandler.Font()
                            }}>
                                { this.state.timelineItems.map((val, index) => { 
                                    return <div key={index}><h2>{val.cardTitle}</h2></div>
                                })}
                            </Chrono>

Expected behavior
When changing the state the timeline should update it's content and display the custom cards

Temporary hack
Create a state with an array with a single empty object of time TimelineItemModel[]
Set Chrono items to the state mentioned above
When updating the custom content also update the items state to be an empty array

this.state = { timelineItems: [], itemUpdateHack: [ {}] }

this.setState({timelineItems: val, itemUpdateHack: []});

<Chrono mode='VERTICAL_ALTERNATING' items={this.state.itemUpdateHack} hideControls={true} allowDynamicUpdate={true} scrollable={false} useReadMore={false} theme={{
                                primary: ThemeHandler.Secondary(),
                                secondary: ThemeHandler.Content('surf'),
                                titleColor: ThemeHandler.Font(),
                                cardBgColor: ThemeHandler.Content(),
                                textColor: ThemeHandler.Font(),
                                cardForeColor: ThemeHandler.Font()
                            }}>
                                { this.state.timelineItems.map((val, index) => { 
                                    return <div key={index}><h2>{val.cardTitle}</h2></div>
                                })}
                            </Chrono>

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions