传递对象文字样式的组件
Passing object literal styled component
我有如下内容:
functionName = () => {
const {
prop1,
prop2,
prop3,
} = this.props;
const collectionOfProps = {
'ONE': prop1,
'TWO': prop2,
'THREE': prop3,
}
return (
<FirstWrapper>
collectionOfProps={collectionOfProps}
</FirstWrapper>
)
}
在我的FirstWrapper
中我有一个这样的函数
const firstConst = ( {collectionOfProps} ) => firstFunction(
collectionOfProps[ONE],
hardCodedValue
)
const firstFunction = (value1, value2) => {
value1 === something
? true
: false
}
但我目前收到以下控制台错误
ONE is not defined
这方面的任何帮助都会很棒!
ONE
应作为字符串传递。您似乎将 ONE
作为作用域中不存在的变量传递。
所以
const firstConst = ( {collectionOfProps} ) => firstFunction(
collectionOfProps["ONE"],
hardCodedValue
)
我有如下内容:
functionName = () => {
const {
prop1,
prop2,
prop3,
} = this.props;
const collectionOfProps = {
'ONE': prop1,
'TWO': prop2,
'THREE': prop3,
}
return (
<FirstWrapper>
collectionOfProps={collectionOfProps}
</FirstWrapper>
)
}
在我的FirstWrapper
中我有一个这样的函数
const firstConst = ( {collectionOfProps} ) => firstFunction(
collectionOfProps[ONE],
hardCodedValue
)
const firstFunction = (value1, value2) => {
value1 === something
? true
: false
}
但我目前收到以下控制台错误
ONE is not defined
这方面的任何帮助都会很棒!
ONE
应作为字符串传递。您似乎将 ONE
作为作用域中不存在的变量传递。
所以
const firstConst = ( {collectionOfProps} ) => firstFunction(
collectionOfProps["ONE"],
hardCodedValue
)