Skip to content
New issue

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

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

Already on GitHub? # to your account

onClick event is not working #114

Open
happy-func opened this issue May 7, 2021 · 7 comments
Open

onClick event is not working #114

happy-func opened this issue May 7, 2021 · 7 comments

Comments

@happy-func
Copy link

import React, { useState } from "react";
import { Button } from "antd";
import { KeepAlive } from "react-keep-alive";

const SchoolList: React.FC = function () {
  const [counter, setCount] = useState(2);
  function addHandle() {
    setCount(counter + 1);
  }
  return (
    <div onClick={addHandle} style={{ position: 'relative', zIndex: 1001 }}>
      {counter}
      <Button>+ 1</Button>
    </div>
  );
};

export default () => (<KeepAlive name="SchoolList"><SchoolList /></KeepAlive>);
@fhyfhytt
Copy link

+1

5 similar comments
@guody
Copy link

guody commented Jun 16, 2021

+1

@Ez-21
Copy link

Ez-21 commented Dec 29, 2021

+1

@ghost
Copy link

ghost commented Feb 19, 2022

+1

@BoBoDinachen
Copy link

+1

@continue2b
Copy link

+1

@continue2b
Copy link

continue2b commented May 11, 2022

I tested the latest react-keep-alive@2.5.2 version with react@16.14.0 and react@17.0.2. The interactions within components seems to break starting from React v17.

react16 working
react17 not working
The only difference between these two examples is the react version.

Most likely it has to do with changes to Event Delegation.

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

No branches or pull requests

6 participants