有没有一种方法可以将ref-virtualized设置为对List的引用?

时间:2020-10-31 22:03:08

标签: javascript reactjs animation react-virtualized refs

我试图通过使用ref在react-virtualized中引用可滚动列表。但是我的裁判总是将其当前属性显示为undefined。有人知道如何将ref与react-virtualized List一起使用吗?

这是我当前正在做的事情,但是listRef.current始终是未定义的:

const listRef = useRef()

<List
      width={350}
      height={400}
      rowCount={listsprings.length}
      rowHeight={100}
      rowRenderer={rowRenderer}
      style={{ outline: 'none' }}
      ref={listRef}
      />

2 个答案:

答案 0 :(得分:0)

您必须使用pass回调,因为它使用LegacyRef

from ctypes import cdll
import os
os.add_dll_directory('C:/Users/User/AppData/Local/Programs/Python/Python38-32/DLLs')
lib = cdll.LoadLibrary("./cconn")


class Foo(object):
    def __init__(self):
        self.obj = lib.Foo_new()

    def bar(self):
        lib.Foo_bar(self.obj)

f = Foo()
f.bar()

答案 1 :(得分:0)

当你使用ref时,你应该关心“listRef.current”而不仅仅是“listRef”