0

I have an data object in a state, like so:

this.state = {
        data: {
            newsData: [],
            eventData: [],
        },
    }

How can I get the number of properties defined in the state data? data.length doesn't work since it's not an array.

Sander Koldenhof
  • 655
  • 9
  • 20
  • [https://stackoverflow.com/questions/46021238/how-to-count-the-length-of-json-response-in-react-native-js](https://stackoverflow.com/questions/46021238/how-to-count-the-length-of-json-response-in-react-native-js) – Özgün Sandal Sep 27 '19 at 14:44

1 Answers1

0

You can use Object.values(data).length