reactjs


How to get DataSource length in react-native?


How do I get the DataSource's length of a ListView?
Suppose I have the following declaration:
const ds = new ListView.DataSource({ rowHasChanged });
...
someObjectsDs = ds.cloneWithRows(someObjectsArray);
I've tried someObjects.length but this returns me undefined.
You can view the amount of rows to be rendered by calling
someObjectsDs.getRowCount()
Official documentation
You can either dig into the datasource object to find the data and grab the length or you can set the data as a property of the component and refer to that:
this.someObjectsArray = someObjectsArray;
someObjectsDs = ds.cloneWithRows(this.someObjectsArray);
Now you will be able to do this.someObjectsArray.length, just make sure you're updating this variable anytime you're updating the datasource.

Related Links

How to pass a value to my parent React component from input type?
why my setTimeout function is not work while I use react-native and react-router-native
React Native - pass class to component as props
mapDispatchToProps with typescript is being difficult
react-form: How to use multiple forms in combineReducers?
React router 4 server-side rendering using IIS, not express
react-bootstrap Cannot read property 'Component' of undefined
Optional Path React Router 4
Synchronize redux from server side with redux from client
React router - Need to click LINK twice to pass props to Component
React native null value checking
Server-side react is not updating with hot reload
Reactjs with fetch for auth and access token, not able to parse response
change text of array item in React: undefined is not a function
How to measure SVG elements in React?
Keeping Material UI tabs and React Router in sync

Categories

HOME
mobile
locale
mysqli
casting
aix
apache-storm
dynamic
data-modeling
arguments
symfony-sonata
mediarecorder
psexec
sequence
install
software-collections
solidity
jetbrains
console-application
simd
react-jsx
openoffice-basic
gomobile
datazen-server
vala
scrapy-spider
chartist.js
stack-trace
gulp-jshint
scripting-language
launchd
restangular
kundera
edirectory
boost-log
textview
ng2-bootstrap
jcr
eclipse-jdt
bootcamp
ragel
gstreamer-1.0
area
lex
jslider
susy
redbean
uitextview
definition
result
hierarchical-clustering
ng-class
beanshell
appcmd
vertex
reloaddata
iban
apache-commons-cli
google-scholar
sqlproj
racket-student-languages
symantec
cherry-pick
db2-zos
abstract
music-player
bluetooth-lowenergy-4.2
kramdown
windows-kernel
javapackager
textblob
avrcp
wingdb
service-broker
pytz
indic
fastcgi-mono-server
mixradio
mahara
mobile-robots
mysql2
magicsuggest
umfpack
cherokee
flexbuilder
method-call
hs-err
response-time
llblgen
nyromodal
table-valued-parameters
iphone-maps
for-xml
ffdshow
weak-typing

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile