Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I want to display the list of contacts on my AVD but Im facing an error (I tried linking the package but it did nothing):

My code :

    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);
      })
    }, []);

The error :

enter image description here

I searched everywhere for a solution but there's nothing about this issue, thanks for helping me by advance.

like image 693
therealwalim Avatar asked Dec 09 '20 17:12

therealwalim


1 Answers

The APIs has been updated in version 6. Changing from callback (version 5 uses callback) to promise worked for me. I mean change -

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

to -

Contacts.getAll()
    .then((contacts) => {
      // work with contacts
    })
    .catch((e) => { //handle error })
like image 108
thebstar Avatar answered Sep 20 '22 10:09

thebstar