colorfy-software / react-native-modalfy

🥞 Modal citizen of React Native.
https://colorfy-software.gitbook.io/react-native-modalfy
MIT License
1.08k stars 44 forks source link

Closing the current modal while opening other #4

Closed syedirfan33 closed 5 years ago

syedirfan33 commented 5 years ago

I am opening an modal upon pressing a button from another modal and would need to close previously opened modal.

Please assist. below code doesn't work.

<Button onPress={this.confirmOrder} title="CONFIRM" />

confirmOrder = () => { const { modal: { openModal, closeModal }, } = this.props; closeModal; openModal('NewOrderPost'); };

CharlesMangwa commented 5 years ago

Hey @syedirfan33! May I ask which version of the library are you using?

syedirfan33 commented 5 years ago

Hey @CharlesMangwa , I am using "react-native-modalfy": "^1.0.0-beta.0",

CharlesMangwa commented 5 years ago

OK got it. Just to understand your issue a bit better I'd have a few questions:

  1. Are the "previously opened modal" and 'NewOrderPost' using the same component?
  2. How many modals do you have in your stack? 2.1 If more than 2, was the "previously opened modal" the latest one opened right before you opened 'NewOrderPost'?
syedirfan33 commented 5 years ago
  1. Yes, I had opened 'NewOrderPre ' before and would need to open 'NewOrderPost' upon clicking 'confirm' button of 'NewOrderPre'

  2. I have only these two 2 modals in stack. const modalConfig = { NewOrderPre, NewOrderPost, };

CharlesMangwa commented 5 years ago

Gotcha! So NewOrderPre and NewOrderPost are using 2 different components under the hood? (could you provide a small reproducible example on Snack plz? Would make it easier to help you as best as I can).

syedirfan33 commented 5 years ago

Hi @CharlesMangwa , sure. I Will do. NewOrderPost and NewOrderPre are two differet compoents.

meanwhile Could you please let me know how can I close current modal upon performing some actions?

CharlesMangwa commented 5 years ago

Oh my bad @syedirfan33! After reading your initial message again I think I've found where your issue might come from: you wrote closeModal; instead of actually calling the function via closeModal();, that's why nothing is happening.

syedirfan33 commented 5 years ago

Omg it's working, thanks a lot!!