pmndrs / leva

🌋 React-first components GUI
https://leva.pmnd.rs
MIT License
5.05k stars 202 forks source link

"Maximum update depth exceeded" when changing values #519

Open d3ttl4ff opened 2 months ago

d3ttl4ff commented 2 months ago

Hi! I'm trying to use leva on my react-three projects but it throws this error when i try to change a value. Screenshot 2024-09-20 134242

Here's a simple code I did

import { useControls } from 'leva';

const Base = () => {
  const { position, scale, color } = useControls({
    position: { value: { x: -2, y: 0 }, step: 0.01, joystick: 'invertY' },
    scale: { value: 1, min: 0, max: 5, step: 0.001 },
    color: '#ff0000',
  });

  return (
    <>
      <mesh position={[position.x, position.y, 0]} scale={scale}>
        <sphereGeometry />
        <meshStandardMaterial color={color} />
      </mesh>

      <mesh position-x={2} scale={1.5}>
        <boxGeometry />
        <meshStandardMaterial color="mediumpurple" />
      </mesh>

      <mesh position-y={-1} rotation-x={-Math.PI * 0.5} scale={10}>
        <planeGeometry />
        <meshStandardMaterial color="greenyellow" />
      </mesh>
    </>
  );
};

export default Base;

In my case it only happens on the position value changes. Scale, Color are working fine without an error. But whenever I try to move the object using the tweaks it throws the error and starts to lag with a significant framerate drop. Does anyone know why this is happening and any possible fixes?