Hi Team, I have created a form with close to 30 fi...
# react
s
Hi Team, I have created a form with close to 30 fields in it and to store the state of those 30 fields I have created a data class and passed that data class to useState hook following the same I used to do in reactJS, however I see some examples with interface in kotlin and wondering if this is the way it should be done in kotlin? and I don’t get why we need an interface and then a data class implementing that interface to manage form state, could someone clarify this please.
a
data classes on kotlin/js work upto a point. If all you do is access the properties, then you will generally get away with a lot. Once you start calling methods (i.e. copy, componentN, toString) on them, you'll start getting a lot of undefined. In all fairness, it is bad practice anyway for state values to have methods. All in all, if you are using data classes just for that holding data (which is what they are for), you do not need to go for interfaces, Unless you are doing class based components
s
thanks @andylamax