如何使用条件渲染来改变已经创建的样式组件的单一属性

34 阅读1分钟

我得到了下面的代码:

function App() {
...
const [message, setMessage] = useState(false);

const styles = {
  backgroundColor:'lightGray',
  ...
}

  return (
         <div>
           <h1> style:{notification ? styles:{styles.backgroundColor:'red'}}>Test</h1>
         </div>
   ) 
}

我想实现的只是改变已经创建的样式的背景颜色属性。