Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal resets sibling component with state #34

Open
Selino opened this issue Sep 30, 2021 · 0 comments
Open

Modal resets sibling component with state #34

Selino opened this issue Sep 30, 2021 · 0 comments

Comments

@Selino
Copy link

Selino commented Sep 30, 2021

I have a stateful component living next to the react-simple-hook-modal. When I trigger the modal it reloads the stateful component. I'm not sure why this is happening. Any advice?

I've tried moving the stateful component outside of the ModalProvider but react-simple-hook-modal still reloads the stateful component, setting it to an empty state.

I don't understand why changing the CSS of the modal div (I assume that's how the package works but I really don't know) that's already on the screen would "reload" anything. 🤷🏽‍♂️

 <ModalProvider>
        <ComponentWithState /> //When the modal pops this is set to initial state
        <Modal
          id='my-modal'
          isOpen={isModalOpen}
          transition={ModalTransition.scale}
        >
          <FontAwesomeIcon
            alt='plus'
            icon={faTimesCircle}
            onClick={closeModal}
            className='absolute top-3 right-3 text-2xl text-gray-600 hover:text-gray-900 cursor-pointer'
          />
        Lorem ipsum
        </Modal>
      </ModalProvider>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant