Jan
Jan

Reputation: 3401

Dynamic refs using ref callback method

How do you suppose setting a dynamic ref now? Im getting an error cannot set property of 'test' undefined, if I use

<View ref={(ref) => this.someRef['test'] = ref;}/>

Upvotes: 6

Views: 1765

Answers (1)

vinayr
vinayr

Reputation: 11234

You have to set this.someRef to an array or object before assigning a property to it.

this.someRef = [];
or
this.someRef = {};

Upvotes: 9

Related Questions