Skip to content

The modal cannot be opened in nextjs app mode #162

@aloha66

Description

@aloha66

Hi please help me.
https://stackblitz.com/edit/stackblitz-starters-ti2xgpmr?description=The%20React%20framework%20for%20production&file=app%2Fpage.tsx,package.json&title=Next.js%20Starter

please download and run local using pnpm. the @ant-design/nextjs-registry can't install using npm ro yarn.

In nextjs, when i click Delete button, antd can't open Modal and raise

hook.js:608 Warning: [antd: Modal] Static function can not consume context like dynamic theme. Please use 'App' component instead.

In vite ,it also raise this warning but it can show Modal

In addition, i add some code to test show Modal in my code, it is fine. like this

 <button
            onClick={() => {
              Modal.confirm({
                icon: null,
                title: 'Delete node',
                content: 'Are you sure you want to delete',
                okButtonProps: { danger: true },
                onOk: () => {},
              });
            }}
        >
          open modal
        </button>

i think , the source code need change to using {modal} = App.useApp() instead Modal.confirm

sorry, i can't upload some picture now , due to github has CORS policy

Access to fetch at 'https://github-production-user-asset-6210df.s3.amazonaws.com/' from origin 'https://github.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions