StructureBuilder / react-keep-alive

A component that maintains component state and avoids repeated re-rendering.
MIT License
981 stars 105 forks source link

onClick event is not working #114

Open happy-func opened 3 years ago

happy-func commented 3 years ago
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 commented 3 years ago

+1

guody commented 3 years ago

+1

Ez-21 commented 2 years ago

+1

ghost commented 2 years ago

+1

BoBoDinachen commented 2 years ago

+1

svtkhn commented 2 years ago

+1

svtkhn commented 2 years ago

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.