这是对上一篇 数据的获取和更改 TS 版解释
//powerCode\countdownCode-->dpCodes的键名
const { powerCode, countdownCode } = DpCodes;
interface HomeBottomViewProps {
theme?: any;
}
const HomeBottomView: React.FC<HomeBottomViewProps> = ({
theme: {
global: { themeColor, fontColor },
},
}) => {
const [isSupportCloudTimer, setIsSupportCloudTimer] = useState(false);
//react-redux useSelector() API 具体 https://blog.csdn.net/qq_33551792/article/details/103514954
const power = useSelector(state => state.dpState[powerCode]);
const countdown = useSelector(state => state.dpState[countdownCode]) as number;
useEffect(() => {
TYSdk.devInfo.panelConfig.bic.forEach(i => {
if (i.code === 'timer' && i.selected) {
setIsSupportCloudTimer(true);
}
});
}, []);
//更改数据
const _handleTogglePower = useCallback(
throttle(() => {
lampPutDpData({ [powerCode]: !power });
}, 200),
[power]
);
零基础涂鸦智能面板SDK开发记录(1/4)_小铁-Android的博客-CSDN博客
零基础涂鸦智能面板SDK开发记录(2/4)_小铁-Android的博客-CSDN博客
零基础涂鸦智能面板SDK开发记录(3/4)-CSDN博客