请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

正在回答 回答被采纳积分+3

1回答

提问者 鎏金华舞 2021-02-26 15:15:08
import React, { useState } from 'react';
import Taro, { useDidShow } from '@tarojs/taro';
import { View, Navigator, Text } from '@tarojs/components';
import './index.less';

export default function Index() {
const [bindPhone, setBindPhone] = useState('');
useDidShow(() => {
const { bindPhone } = Taro.getStorageSync('person');
setBindPhone(bindPhone);
});

return bindPhone ? (
<View className="login-components">
<Navigator className="login-content font-medium" url="/page/registerPack/index">
<View className="login-text">登录 / 注册 </View>
</Navigator>
</View>
) : null;

}

请问,我想测试 bindPhone 有值的情况下渲染这个组件,没有值的情况不渲染。如何去测试mock呢,写了很久,网上没找到好的例子


0 回复 有任何疑惑可以回复我~
  • Dell #1
    参考这篇文章,一看就懂:https://dev.to/theactualgivens/testing-react-hook-state-changes-2oga
    回复 有任何疑惑可以回复我~ 2021-02-28 22:05:48
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信