Giter Club home page Giter Club logo

Comments (5)

2788 avatar 2788 commented on September 17, 2024

看了在线例子, 好像是在一个专门的地方渲染组件, 然后通过createPortal转移到真实dom上面?
不知道我理解有没有错误,反正能看出来跟逻辑上的组件树会有出入,在keepAlive父级添加click事件,在keepalive上面点击 父级不会响应

from react-keep-alive.

guoyunhe avatar guoyunhe commented on September 17, 2024

我看很多人遇到了 state 不能和 在同一级用的问题:

export function App() {
  const [value, setValue] = useState('');
  return <KeepAlive>
    <input value={value} setValue={e => setValue(e.target.value)}
  </KeepAlive>
}

我想能不能不用组件的方式提供 keep alive 而是用 HOC,这样就不用担心有人在同一层用 state 和 keep alive 了:

function App() {
  const [value, setValue] = useState('');
  return <input value={value} setValue={e => setValue(e.target.value)}
}

export keepAlive(App);

from react-keep-alive.

guoyunhe avatar guoyunhe commented on September 17, 2024

希望能够支持手动卸载,以免有些情况下内存消耗太大

from react-keep-alive.

svtkhn avatar svtkhn commented on September 17, 2024

Seems like React v18 is planning to finally officially support keep-alive feature. They call it <Offscreen>. Hopefully, it will be released soon enough so we don't have to hack around current React's limitations.

from react-keep-alive.

shenjunru avatar shenjunru commented on September 17, 2024

欢迎试用 react-fiber-keep-alive,一个基于 react fiber 的 keep-alive 实现

Give a try react-fiber-keep-alive, the react fiber based keep-alive implementation.

from react-keep-alive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.