Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element Style Cleanup Incomplete Causes Invisible Cursor #67

Open
MarkintoshZ opened this issue Feb 18, 2024 · 0 comments
Open

Element Style Cleanup Incomplete Causes Invisible Cursor #67

MarkintoshZ opened this issue Feb 18, 2024 · 0 comments

Comments

@MarkintoshZ
Copy link

Description

If AnimatedCursor is rendered conditionally, the cursor will stay invisible even when AnimatedCursor is removed from the render tree.

To Produce

import { useState } from "react";
import AnimatedCursor from "react-animated-cursor";

function App() {
  const [count, setCount] = useState(0);

  return (
    <>
      <button onClick={() => setCount((count) => count + 1)}>
        count is {count}
      </button>
      {count <= 1 && <AnimatedCursor />}
    </>
  );
}

export default App;

Potential Fix

These lines for removing event listeners seems suspicious. Although they might not directly relate to this issue, they seem wrong. The correct way is to create a named function for the event handler and pass that to the removeEventListener function. Otherwise, the added listeners are separate object than the listeners that are specified to remove.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant