mastermoo / react-native-action-button

customizable multi-action-button component for react-native
MIT License
2.52k stars 570 forks source link

Unable to Add Action Buttons dynamically #348

Closed karanasthana closed 4 years ago

karanasthana commented 4 years ago

Unable to Add ActionButton Items dynamically.

I have the following setup --

<ActionButton>
    <ActionButton.item name={constant_btn1} />
    <ActionButton.item name={constant_btn2} />
</ActionButton>

I want to add dynamic buttons to this list. (The list is received from backend)

I have created a function that returns me views of these buttons.

getDynamicBtns() {
    dynamicButtonsList.map(item, key) => {(
        return <ActionButton.item name={item.btnName} />;
    )};
}

and I have used it in this way inside my render() function -->

<ActionButton>
    <ActionButton.item name={constant_btn1} />
    <ActionButton.item name={constant_btn2} />
    {this.getDynamicBtns}
</ActionButton>

So this is rendering my constant buttons, but not the dynamic buttons.

karanasthana commented 4 years ago

The dynamic buttons were being added as an array of buttons instead of adding buttons one by one. Rest, worked fine.