我需要将js定义的一些style传到一个第三方库里,但是貌似state更新后并没有重新渲染样式,我确定组件是更新了,但是这个第三方库传进去的样式未更新,有人帮忙解决下吗?
代码如下
class Console extends React.Component {
getConsoleFeedStyle(theme) {
const style = {};
switch (theme) {
case 'light':
return Object.assign(style, a);
case 'dark':
return Object.assign(style, b);
case 'contrast':
return Object.assign(style, c);
default:
return '';
}
}
render() {
return (
<div>
{this.props.consoleEvents.map((consoleEvent) => {
const { theme } = this.props;
return (
<div key={consoleEvent.id}>
<ConsoleFeed
styles={this.getConsoleFeedStyle(theme)}
logs={Array.of(consoleEvent)}
/>
</div>
);
})}
</div>
</div>
);
}
}
这个是个组件,又不是div。。。
你style传过去,他组件里又不用,你传过去有什么用