我正在尝试使用 react-redux 将主题切换与暗模式和亮模式一起使用。
import { useSelector } from 'react-redux';
const darkMode = {
primary: 'black',
secondary: 'white',
}
const lightMode = {
primary: 'white',
secondary: 'black',
}
function ColorMode(){
const mode = useSelector(state => state.getDarkMode.darkMode); // Calling from redux saga
return mode ? darkMode : lightMode
}
import { useSelector } from 'react-redux';
import Color from 'Color';
const App = () => {
console.log('Here it is working...', Color.primary) // black
return (
<View style={{backgroundColor: Color.primary}} /> // Here not working
<Text style={{color: Color.secondary}} /> // Here not working
</View>
)
}
错误:呈现的钩子比预期的少。这可能是由于意外的提前退货声明造成的。