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

Sheet not opening in StrictMode #185

Open
Chrishuwei opened this issue Dec 28, 2024 · 4 comments
Open

Sheet not opening in StrictMode #185

Chrishuwei opened this issue Dec 28, 2024 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Chrishuwei
Copy link

I am trying this module in my page. However, I cannot see the sheet in view because we set transform value is css. Also, we do not have this behavior in the release environment (I deployed my website through GCP).

One more interesting thing is if I zoom in and out by cmd +/-, then I can see the sheet rendering in view when I am in development mode.

Is this a known issue of this module? Or is there any workaround to prevent this issue? Thank you.

CODE:
'use client';
import { Sheet } from 'react-modal-sheet';
import { useState } from 'react';

export default function Container() {

const [isOpen, setOpen] = useState(false);

return (
    <div>
        <div>this is container</div>
        <button onClick={() => setOpen(true)}>Open sheet</button>

        <Sheet
            isOpen={isOpen}
            onClose={() => setOpen(false)}
            snapPoints={[-50, 0.5, 200, 0]}
            initialSnap={1}
        >
            <Sheet.Container>
                <Sheet.Header />
                <Sheet.Content>
                    <div style={{ 'color': 'black' }}>We will have product content here</div>
                </Sheet.Content>
            </Sheet.Container>
            <Sheet.Backdrop />
        </Sheet>
    </div>
)

}

@Temzasse
Copy link
Owner

Hi @Chrishuwei 👋🏻

This sounds like it could be a React StrictMode related issue. For some reason the motion library that react-modal-sheet relies on struggles with StrictMode causing the opening animation of the sheet to not trigger correctly. The reason things work for you in production is because StrictMode is only enabled in development mode.

Unfortunately I haven't been able to figure out a workaround yet. Currently the easiest fix is to just turn off/remove React StrictMode.

@Temzasse Temzasse changed the title transform is set to translateY(1234px) when I am working in localhost. Sheet not opening in StrictMode Dec 30, 2024
@Temzasse Temzasse added bug Something isn't working help wanted Extra attention is needed labels Dec 30, 2024
@Temzasse
Copy link
Owner

I updated the title to reflect the real root cause of the problem.

I'll keep this issue open so that other devs that encounter the same issue can see it and maybe someone has an idea how to mitigate the problem. I currently don't have much time to investigate this problem.

@xsjcTony
Copy link

Are you using React 18 or 19?
I don't have any issue with StrictMode enabled in React 18

@Temzasse
Copy link
Owner

Temzasse commented Jan 2, 2025

I'm using React 19. As part of the v4 refactoring of react-modal-sheet I also updated the example app that I use for local development to use v19 and this issue happens there if I enable StrictMode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants