You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using react-table together with TypeScript and a functional programming oriented code base. Because of this, I ran into a problem when passing my data to useTable.
Above code would give me a compilation error since the data passed to useTable has to be of type Array but my data is of type ReadonlyArray. I did go through the source code of useTable and could not find any place where data is directly modified, but I wanted to double check here first. (I don't want any hard to track down bugs.). If useTable is indeed a pure function (with regards to data and columns), then I can easily short term solve my problem by doing:
and then also do a PR to the type definitions repository (it is possible to pass an object of type Array to a function that take the type ReadonlyArray, but not the other way around).
Also if you read this Tanner, I just want to say that this is an awesome library and I can't wait to get to learn even more of it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I'm using react-table together with TypeScript and a functional programming oriented code base. Because of this, I ran into a problem when passing my data to
useTable
.Above code would give me a compilation error since the
data
passed touseTable
has to be of typeArray
but mydata
is of typeReadonlyArray
. I did go through the source code ofuseTable
and could not find any place where data is directly modified, but I wanted to double check here first. (I don't want any hard to track down bugs.). IfuseTable
is indeed a pure function (with regards todata
andcolumns
), then I can easily short term solve my problem by doing:and then also do a PR to the type definitions repository (it is possible to pass an object of type
Array
to a function that take the typeReadonlyArray
, but not the other way around).Also if you read this Tanner, I just want to say that this is an awesome library and I can't wait to get to learn even more of it.
Beta Was this translation helpful? Give feedback.
All reactions