Kieran-McIntyre / react-native-section-alphabet-list

A simple React Native component that takes an array of data and renders a SectionList with alphabetically sorted data
MIT License
195 stars 55 forks source link

Cannot read properties of null (reading 'substring') #50

Closed ahsanparacha02 closed 2 years ago

Mohammadrezaymd commented 1 year ago

How did you fix this issue? I have the same error @ahsanparacha02

ahsanparacha02 commented 1 year ago

How did you fix this issue? I have the same error @ahsanparacha02

u must add value and key property in your json list like this

 res.response.list.map((item, index) => {
            tempList.push({
              ...item,
              value: item.member_username,
              key: item.friend_id,
       });
})
Raiden-16F7 commented 10 months ago

@ahsanparacha02 But what if my value is null from API, it shows this same error

// Map the data to key-value structure
        const mappedEventUsers = apiData.map((user) => ({
          key: user.id.toString(),
          value: user.name,
          ...user,
        }));
        setEventUsers(mappedEventUsers);