brainhubeu / react-carousel

A pure extendable React carousel, powered by Brainhub (craftsmen who ❤️ JS)
https://brainhub.eu/
MIT License
1.07k stars 165 forks source link

Update to children elements (slides) are not rendered #636

Open taijuten opened 3 years ago

taijuten commented 3 years ago

Describe the bug If a child element is updated (in this case, a className) this is not re-rendered.

To Reproduce Steps to reproduce the behavior:

class MyCarousel extends React.Component { constructor() { super() this.state = { selected: null }; }

render() { return (

this.setState({ selected: 0 })} src={imageOne} className={!this.state.selected ? 'active' : ''} />), ( this.setState({ selected: 1 })} src={imageTwo} className={this.state.selected === 1 ? 'active' : ''} />), ( this.setState({ selected: 2 })} src={imageThree} className={this.state.selected === 2 ? 'active' : ''} />), ]} />
);

} }



**Expected behavior**
On click of each image, it should apply an `active` class.
This is not the case. According to React debug this is passing correct props, but not being rerendered.
HabibaGadalla commented 3 years ago

i'm having the same issue

AlexKvazos commented 3 years ago

The carousel seems to internally manipulate the dom without React so anytime you re-render it it will clear the dom manipulations and render blank. Seems like this is not possible to fix with the current architecture. Having the same issue and gave up in favor of https://www.npmjs.com/package/pure-react-carousel