ant-design: Ant Design Component Causing Error ReactRender Is Not A Function
Reproduction link
Steps to reproduce
- Create a new project using Next.js 15.
- Install antd version 5.22.5.
- Wrap root layout with <AntdRegistery>
- Import the Button component from antd into the
page.tsxfile. - Use the Button component in that Page.
- Run the application using
npm run dev.
What is expected?
When I click the button, the onClick function attached to the button should be executed without errors, and no TypeError or other issues should occur.
What is actually happening?
When I use the button from antd (So far I only use the button), when I click on it, the TypeError error occurs: reactRender is not a function.
I’ve checked it works regardless of whether you use the client or the server. I am using extjs 15 and the latest version of antd. I also tried to create a new clean next project and try it there, but the error is the same.
| Environment | Info |
|---|---|
| antd | 5.22.5 |
| React | 19.0.0 |
| System | Nextjs 15 |
| Browser | Chrome:latest |
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 24 (1 by maintainers)
I tried this (https://ant.design/docs/react/v5-for-19) workaround, however after installing the package and adding
import "@ant-design/v5-patch-for-react-19";in either the rootlayout.tsxor directly in the target component, I started getting another error:Export unstableSetRender doesn't exist in target module. It looks like this module is not present in theantdpackage. Any ideas?Full error:
Update: Make sure that you are on
"antd": "^5.23.1"or above, since if you are below that, you will run into the same issue as me.yes when click happens
Applying
@ant-design/v5-patch-for-react-19– didn’t help, the error didn’t go away. However, I was able to add a workaround by rendering the portal components as in the following code:dependencies: “react”: “19.0.0”, “react-dom”: “19.0.0”, “antd”: “5.24.1”,
P.S. I definitely think the antd team (@afc163) needs to add a full-fledged example of using
unstableSetRender, particularly for typescript projects.It seems like you’re encountering a
TypeErrorwith the message “reactRender is not a function” when using the Ant Design Button component in a Next.js 15 project. This error might be related to compatibility issues between the versions of React, Next.js, and Ant Design you’re using.Here are a few steps you can take to troubleshoot and potentially resolve the issue:
Check React Version Compatibility: Ensure that the version of React you’re using is compatible with Ant Design 5.22.5. The error message suggests a potential mismatch or missing dependency.
Verify Ant Design Installation: Double-check that Ant Design is installed correctly. You can try reinstalling it using
npm install antd@5.22.5.Review Next.js Configuration: Ensure that your Next.js configuration is set up correctly to work with Ant Design. This includes checking if any custom webpack configurations might be affecting the build.
Check for Known Issues: Look for any known issues or discussions in the Ant Design GitHub repository or community forums that might relate to this error.
Simplify the Setup: Try creating a minimal setup with just the Button component to isolate the issue. This can help determine if the problem is with the integration or a specific part of your project.
Update Dependencies: Ensure all your dependencies are up to date, including React, Next.js, and Ant Design.
If these steps do not resolve the issue, it might be helpful to search for similar issues in the Ant Design GitHub repository to see if others have encountered and resolved this problem. If the issue persists, you may consider opening a new issue with detailed reproduction steps for further assistance.
If you need more specific guidance, please let me know!
🪧 Tips
For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me.For me it was resolved by returning to react ^ 18
antD can show some compatibility issues if u are using react ^19, so, first, check your react version in package.json, if your react version is 19, this command might help you:
first, you should run this script in your frontend package terminal:
npm install --save-dev @ant-design/v5-patch-for-react-19
and then, you have to import the antd compatibility patch in your jsx archive, just like this:
import ‘@ant-design/v5-patch-for-react-19’;
Issue is still there on 5.22.5. Pops up when clicking an AntD button.
It seems like you are encountering a
TypeErrorwith the message “reactRender is not a function” when using the Ant Design Button component in a Next.js 15 project. This issue might be related to compatibility between the versions of React, Next.js, and Ant Design you are using.Here are a few steps you can take to troubleshoot and potentially resolve the issue:
Check React Version: Ensure that the version of React you are using is compatible with Ant Design 5.22.5. The error message suggests that there might be an issue with the rendering process, which could be due to an incompatible React version.
Verify Ant Design Setup: Make sure that Ant Design is correctly set up in your project. This includes ensuring that the CSS is properly imported and that any necessary configurations for server-side rendering (SSR) with Next.js are in place.
Update Dependencies: Sometimes, updating your dependencies to the latest versions can resolve compatibility issues. Ensure that you are using the latest stable versions of React, Next.js, and Ant Design.
Check for Known Issues: Look for any known issues or bug reports related to the versions you are using. This can be done by searching the Ant Design GitHub repository for similar issues.
Simplify the Setup: Try creating a minimal reproduction of the issue by stripping down your setup to the bare essentials. This can help identify if there is a specific part of your setup causing the problem.
Consult Documentation: Review the documentation for Ant Design and Next.js to ensure that you are following the recommended practices for integrating these libraries.
If these steps do not resolve the issue, you may want to provide more detailed information about your setup or consider reaching out to the community for further assistance.
If you have any more questions or need further assistance, feel free to ask!
🪧 Tips
For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me.