1

I'm building an application that allows users to browse but will prompt them to login if they try to perform an action (e.g. liking something, trying to post something)

To achieve this, I have created a registration form which appears in a React-Bootstrap modal.

My question is, how can I trigger that modal to appear from multiple different components (for example a 'like' button component, or the 'sign up' component, or an 'upload' component)

I am not using redux, my application is a Meteor application.

My current idea: Add the modal open/close state to the top level component (App) and manipulate that state from the children components when the user clicks them?

Sean
  • 2,609
  • 1
  • 18
  • 34
  • I think your current idea is the only way without using some global state like `redux` or `mobx` – canaan seaton Aug 21 '17 at 15:32
  • You approach sounds fine, I'm not sure what you mean by "manipulate the state from children", so I'll suggest that you should create a modal open method in the top level `App` component and pass that to any children who need to trigger the modal. – Rob M. Aug 21 '17 at 15:32
  • Possible duplicate of [How can I display a modal dialog in Redux that performs asynchronous actions?](https://stackoverflow.com/questions/35623656/how-can-i-display-a-modal-dialog-in-redux-that-performs-asynchronous-actions) – lux Aug 21 '17 at 15:44

0 Answers0