简体   繁体   English

React + .jsx + Spread运算符—添加样式?

[英]React + .jsx + Spread Operator — Add a Style?

I have a React element (courtesy of the excellent Downshift library) that looks like this: 我有一个React元素(由出色的Downshift库提供)看起来像这样:

<mySearchResults
    {...{
        inputValue,
        selectedItem,
        highlightedIndex,
        getItemProps,
    }}
/>

I need to add a .jsx style to it: 我需要添加一个.jsx样式:

 style: styles.searchResultsContainer

I've tried a couple ways of adding it, including: 我尝试了几种添加方式,包括:

<mySearchResults
    {...{
        inputValue,
        selectedItem,
        highlightedIndex,
        getItemProps,
        style: styles.searchResultsContainer
    }}
/>

It builds and runs without errors, but it doesn't seem to get the styles into the element. 它的构建和运行没有错误,但似乎并未将样式纳入元素。

What is the correct syntax for this? 正确的语法是什么?

That should be correct. 那应该是正确的。 Are you sure your mySearchResults component is set up to accept a style prop? 您确定将mySearchResults组件设置为接受样式道具吗?

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

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