Git Product home page Git Product logo

Comments (6)

stackblitz avatar stackblitz commented on September 24, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

from ant-design.

wanpan11 avatar wanpan11 commented on September 24, 2024

这个问题好坑 🤧
你在例子里的写法存在一个问题,form 的 onChange 更新应该是非高优先级的,你先调用了 setOpen(false) 造成了 value 还没更新 open 已经 false 了,Cascader.Panel 组件就没有 update 了

image

延迟更新下 就好了

            onChange={(e) => {
              startTransition(() => setOpen(false));
              onChange?.([value[0], e[0]]);
            }}

image

from ant-design.

crazyair avatar crazyair commented on September 24, 2024

这个问题好坑 🤧 你在例子里的写法存在一个问题,form 的 onChange 更新应该是非高优先级的,你先调用了 setOpen(false) 造成了 value 还没更新 open 已经 false 了,Cascader.Panel 组件就没有 update 了

image

延迟更新下 就好了

            onChange={(e) => {
              startTransition(() => setOpen(false));
              onChange?.([value[0], e[0]]);
            }}

image

setTimeout 大法好,其实问题是,value 设置值后,立刻卸载了 Cascader,导致 Cascader value 有 bug 了,当 value 再设置 undefined 也不会清空 Cascader 选中态,这个 Cascader 需要修复下 bug

from ant-design.

wanpan11 avatar wanpan11 commented on September 24, 2024

setTimeout 大法好,其实问题是,value 设置值后,立刻卸载了 Cascader,导致 Cascader value 有 bug 了,当 value 再设置 undefined 也不会清空 Cascader 选中态,这个 Cascader 需要修复下 bug

不是的 我 debugger 了 Cascader ,你用的是 From 的 onChange ,没有 useState 更新来的优先级高,Cascader 没有收到更新就被卸载了

from ant-design.

crazyair avatar crazyair commented on September 24, 2024

setTimeout 大法好,其实问题是,value 设置值后,立刻卸载了 Cascader,导致 Cascader value 有 bug 了,当 value 再设置 undefined 也不会清空 Cascader 选中态,这个 Cascader 需要修复下 bug

不是的 我 debugger 了 Cascader ,你用的是 From 的 onChange ,没有 useState 更新来的优先级高,Cascader 没有收到更新就被卸载了

但是再加载,value 是undefined,为什么没清空

from ant-design.

wanpan11 avatar wanpan11 commented on September 24, 2024

但是再加载,value 是undefined,为什么没清空

初始化的时候就是 undefined ,你传进来的 value = undefined,界面显示出来 是因为 Cascader 内部也有一个自己的 value

from ant-design.

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.