V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
nowant
V2EX  ›  问与答

提一个关于 Compose 的问题,关于 LazyColumn 组件的内部抛出的异常如何定位?

  •  
  •   nowant · Nov 1, 2024 · 1152 views
    This topic created in 547 days ago, the information mentioned may be changed or developed.

    在使用 LazyColumn 的时候,为了优化性能可以给 item 设置 key ,但我们要保证 item 的 key 在整个列表中是唯一的。有时候我们使用的 key 是通过后端传过来的,如果后端传的 key 出现重复,程序就会发生异常。 但我们的一个 app 会在很多业务中使用 LazyColumn ,并且给 item 设置 key ,如果出现这个异常,我们如何定位是哪个业务中使用的 LazyColumn 抛出来的异常。

    java.lang.IllegalArgumentException: Key "0" was already used. If you are using LazyColumn/Row please make sure you provide a unique key for each item.
    

    目前的堆栈中不包含任何业务代码的堆栈,调用链是从 handle dispatchMessage 开始,一直到 compose 源码? 请问遇到这种问题除了,自定义日志以外,能不能通过 modifier 给组件设置一个标识,然后异常堆栈会附带这个标识。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   825 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 19:44 · PVG 03:44 · LAX 12:44 · JFK 15:44
    ♥ Do have faith in what you're doing.