question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Refine > 3.20 NextJs Antd useEditableTable and useModalForm hooks do not work

See original GitHub issue

Describe the bug

On nextjs refine version greater than 3.20, some antd hooks do not work: useEditableTable and useModalForm

To Reproduce Steps to reproduce the behavior:

  1. Instantiate a nextjs refine project
npx superplate-cli -p refine-nextjs tutorial

✔ Cloned remote source successfully.
✔ What will be the name of your app · tutorial
✔ Do you want to use an UI Framework?: · antd
✔ Do you want to customize theme?: · css
✔ Data Provider: · custom-json-rest-data-provider
✔ Auth Provider: · custom-auth-provider
✔ Do you want to add an example page? · example-resource
✔ Do you want to customize layout? · custom-layout
✔ i18n - Internationalization: · i18n-antd
✔ Would you like to share your choices with us anonymously? · no
  1. Edit posts list screen

Use ‘useEditableTable’ instead of 'useTable’i in ‘/src/components/posts/list.tsx’

const { 
    isEditing,
    saveButtonProps,
    cancelButtonProps,
    editButtonProps,
    tableProps, sorter } = useEditableTable<IPost>({});
<Table.Column<IPost>
        title="Inline Actions"
        dataIndex="inlineActions"
        key="inlineActions"
        render={(_text, record) => {
            if (isEditing(record.id!!)) {
                return (
                    <Space>
                        <SaveButton {...saveButtonProps} size="small" />
                        <Button {...cancelButtonProps} size="small">
                            Cancel
                        </Button>
                    </Space>
                );
            }
            return (
                <Space>
                    <EditButton
                        {...editButtonProps(record.id!!)}
                        size="small"
                    />
                </Space>
            );
        }}
    />
  1. Launch server and go to posts listing page: http://localhost:3000/posts
  2. You are redirected on https://api.fake-rest.refine.dev/posts/undefined

Expected behavior

Inline editing must be active. If I use the web app version of refine npx superplate-cli -p refine-react tutorial, it works.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
clebeaupincommented, Jun 14, 2022

I found a fix. As you suggested, I have updated to the latest version of next.js Then I set in next.config.js the experimental feature: newNextLinkBehavior: true

0reactions
omeraplakcommented, Jun 14, 2022

It does not work on my side. I still have the same behaviour

Can you upgrade your Next.js dependency to the latest version? (I updated the version now on superplate)

npm i next@latest

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] refine 3.23.2 does not work on nextjs: Multiple children ...
Describe the bug The last version of refine 3.23.3 does not work with ... other issues with antd hooks : useEditableTable and useModalForm...
Read more >
Funny Modal hook BUG - Ant Design
BUG. From the figure above, we can see that when contextHolder is placed inside Modal , the pop-up position of the hooks call...
Read more >
useModalForm - Refine Dev
useModalForm hook allows you to manage a form within a modal. It returns Ant Design Form and Modal components props.
Read more >
Nextjs throws React has detected a change in the order of ...
Using hooks this way is a bad practice for this exact reason. It works fine, but only under certain conditions, making the code...
Read more >
useModalForm
close, Specify a function that can close the modal, () => void. visible, Whether the modal dialog is visible or not, boolean. formProps,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found