Error while updating property 'accessibilityState' of a view managed by: RCTView
null
Value for disable cannot be cast from ReadableNativeMap to Boolean.
执行此代码片段时出现此消息
const onCheck = async () => {
if (!itemQuestion?.answer && itemQuestion?.type !== 'sorting_choice') {
Alert.alert('', t('learningScreen.quiz.checkAlert'));
return;
}
setIsLoading(true);
const itemTemp = new Object() as any;
if (itemQuestion?.type === 'sorting_choice') {
itemTemp.value = itemQuestion?.options.map((y: any) => y.value);
} else if (itemQuestion?.answer) {
if (itemQuestion?.type === 'true_or_false') {
itemTemp.value = itemQuestion?.answer.value;
} else if (itemQuestion?.type === 'fill_in_blanks') {
itemTemp.value = itemQuestion?.answer;
} else if (itemQuestion?.type === 'multi_choice') {
itemTemp.value = itemQuestion?.answer.map((y: any) => y.value);
} else {
itemTemp.value = itemQuestion?.answer.map((y: any) => y.value);
}
}
const param = {
id: item?.id,
question_id: itemQuestion?.id,
answered: itemTemp?.value,
};
const checkAnswerPayload = await checkAnswer(param, token, navigation);
if (checkAnswerPayload?.code === 'cannot_check_answer') {
Alert.alert(checkAnswerPayload?.message || "");
}
console.log(checkAnswerPayload)
const dataTemp = {
id: itemQuestion?.id,
result: checkAnswerPayload.result,
explanation: checkAnswerPayload?.explanation || "",
};
itemCheck.push(dataTemp);
setItemCheck((prevItemCheck) => [...prevItemCheck, dataTemp])
setIsLoading(false);
};
预计可以正常工作,但显示上述错误。
我也有同样的问题。我有一个正在使用组件并向该组件传递布尔值的屏幕。问题在于这个组件以及我如何获取该值。父组件就像包含这样的组件:
<BecomeAMember loading={loading} />
组件看起来像这样(当错误存在时):
const BecomeAMember = (loading: boolean) => {
我已经改成
const BecomeAMember = ({loading}: any) => {
错误消失了。看来我必须先破坏这些属性了。
为了更好地打字,我将代码更改为:
interface BecomeAMemberProps {
loading: boolean;
}
const BecomeAMember: React.FC<BecomeAMemberProps> = ({loading}) => {
/*rest of the code */
}