m-list-view
m-list-view copied to clipboard
在内部使用sticky时报错
需求是: 长列表只有一个吸顶,不是示例的那种很多标题吸顶, 所以我就改了一下, 把StickyContainer 放在了renderSectionBodyWrapper里面渲染 把Sticky 放在 renderHeader 里面渲染 复现:https://codesandbox.io/s/04xozqryjv code:
export default class Demo extends React.Component {
...
return (
<ListView
ref={el => this.lv = el}
dataSource={this.state.dataSource}
className="am-list sticky-list"
// useBodyScroll
renderSectionBodyWrapper={() => (
<StickyContainer
// key={`s_${sectionID}_c`}
className="sticky-container"
style={{ zIndex: 4 }}
/>
)}
renderHeader={() => (
<Sticky>
{({
style,
}) => (
<div
className="sticky"
style={{
...style,
zIndex: 3,
backgroundColor: '#F8591A',
color: 'white',
}}
>{`Task 1`}</div>
)}
</Sticky>
)}
...
然而结果却是 Uncaught TypeError: Expected Sticky to be mounted within StickyContainer
,
该怎么解决呢?