简体   繁体   English

React JSX无法访问div中的变量

[英]React JSX Unable to access variable inside div

I'm currently rendering a list which I've defined in the render method, like so 我目前正在渲染我在render方法中定义的列表,像这样

        render() {
            var listDisplay = items.map((item, i) => {
                ....
            }

            return (
                <TabPanel>
                    <Scrollbars>
                        {listDisplay}
                    </Scrollbars>
                </TabPanel>
            )
        }

This works as intended and the listDisplay shows up correctly. 这可以按预期工作,并且listDisplay可以正确显示。 However, when I surround the Scrollbars with <div> , nothing shows up. 但是,当我用<div>包围滚动条时,没有任何显示。

I feel like I might be missing something obvious, but right now I have no clue what's going on. 我觉得我可能缺少明显的东西,但是现在我不知道发生了什么。 Any ideas? 有任何想法吗?

As one of the comments above suggested, it was a layout issue rather than being unable to access the variable. 正如上面的评论之一所建议的,这是一个布局问题,而不是无法访问该变量。 In this case, using <div> tags around the Scrollbar component alters the layout. 在这种情况下,在Scrollbar组件周围使用<div>标签会更改布局。 Getting rid of it fixed the problem. 摆脱它可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM