来自 JS 的格式错误的调用:字段大小不同 [[8,39],[4,0]

Malformed calls from JS : field sizes are different [[8,39],[4,0]

我想在我的 AVD 上显示联系人列表,但我遇到了一个错误(我尝试链接包但它什么也没做):

我的代码:

    const [contact, setContact] = useState([]);
  
    useEffect(() => {
      PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
        {
          'title': 'Contacts',
          'message': 'This app would like to view your contacts.'
        }
      ).then(() => {
        Contacts.getAll((err, contacts) => {
          if (err === 'denied'){
            // error
          } else {
            // contacts returned in Array
            setContact(contacts);
            console.log(contact);
          }
        })
      })
      .catch((err)=> {
          console.log(err);
      })
    }, []);

错误:

我到处找解决方案都没有解决这个问题,谢谢你提前帮助我。

A​​PI 已在版本 6 中更新。从回调(版本 5 使用回调)更改为 promise 对我有用。我的意思是改变 -

Contacts.getAll((err, contacts) => { });

到-

Contacts.getAll()
    .then((contacts) => {
      // work with contacts
    })
    .catch((e) => { //handle error })

Contacts.getAll()
    .then((contacts) => {
      // work with contacts
    })
    .catch((e) => { //handle error })

对我有用

使用更新的API版本,您需要将回调语法更改为promise .then 和.catch,例如

Contacts.getAll()
    .then(contacts => { //your code here })
    .catch(e => { //handle error })