naoufal / react-native-accordion

An Accordion Component for React Native
https://www.npmjs.com/package/react-native-accordion
437 stars 101 forks source link

[height] Updated componentWillReceiveProps to adjustify content height #11

Closed techmentormaria closed 8 years ago

techmentormaria commented 8 years ago

The other pull request didn't work for me, so I created this one. Would be great if you include that in the basic project.

-M

naoufal commented 8 years ago

Thanks for taking the time to submit a PR @mhollweck. I'm always happy to see people contribute. :smile:

naoufal commented 8 years ago

Closing due to inactivity.

compojoom commented 7 years ago

@naoufal - sorry to be a trouble, but can we get something in the core? You've closed 4 in favor of 11. But you've closed 11 due to inactivity. In the meantime I'm just extending your class and adding a componentWillReceiveProps function:

var Accordion = require('react-native-accordion');

Accordion.prototype.componentWillReceiveProps = function(nextProps) {
    if(!this.state.is_visible)
    {
        setTimeout(this._getContentHeight);
    }
};

module.exports = Accordion;

If we don't check the is_visible state, then we can't close the item, because on each new prop we'll update the height...

Having the Accordion automatically resize is important when you are dynamically adding items to the content.

naoufal commented 7 years ago

@compojoom you're right. I haven't been around as much as I would have liked to. At the same time, it's difficult to move a an Issue/PR along without both parties actively moving it forward.

That said, this repo deserves more attention and collaborators. I'd be happy to make you one if you're up for it.