konvajs / react-konva

React + Canvas = Love. JavaScript library for drawing complex canvas graphics using React.
https://konvajs.github.io/docs/react/
MIT License
5.8k stars 260 forks source link

react-konva is breaking with nextjs 15. Cannot read properties of undefined (reading 'ReactCurrentOwner') #814

Closed heyletscode closed 3 weeks ago

heyletscode commented 4 weeks ago

The library works well with nextjs 14 but breaks with next 15. I have tried back and forth with next version 14 and 15 to make sure thats the only variable and yeah it only breaks with version 15.

Screenshot 2024-11-02 132752

lavrton commented 3 weeks ago

You can try npm install react-konva@19.0.0-1. But I am waiting for official release of react@19.

Fearless09 commented 2 weeks ago

@lavrton I also had the same issue, and npm install react-konva@19.0.0-1 fixed the error. But now I am having a Cannot find module 'canvas error and I have tried:

const nextConfig = {
  webpack: (config) => {
    config.externals = [...config.externals, { canvas: 'canvas' }]; // required to make Konva & react-konva work
    return config;
  },
};

module.exports = nextConfig;

But it didn't fixed the error, please how can I fix this error?