自定义组件传输变量时报警告
it looks like an unknown prop “***
” is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via <StyleSheetManager shouldForwardProp={...}>
(connect an API like @emotion/is-prop-valid
) or consider using transient props ($
prefix for automatic filtering.)
意思是我们向DOM传输了一个未知的prop变量,触发了React的警告,想要消除警告我们可以安装类似于@emotion/is-prop-valid
的插件或者在传入的变量前加$
符号,我这里采用加$
符号解决(注意从props取值时也要加$
)
改之前
- 传入
- 使用
改之后
- 传入
- 使用