I am developing a native UI component for React Native (this question concerns Android). I manage to pick up component props at the android side with @ReactProp as described here. The problem comes to when I am trying to read the regular style prop in the same way. It simply won't get into the function a wrote:
@ReactProp(name = "style")
public void setStyle(PickerView view, @Nullable ReadableMap style) {
// never reaching here
}
Any other property name seems to work. I guess it's because the style prop is handled differently. How can I access the provided style prop?
To access the style prop in Android, you can use ReactPropGroup like so:
@ReactPropGroup(names = {"height", "width", "zIndex", "right", "top"}, customType = "Style")
public void setStyle(PickverView view, int index, Integer style) {
//
}}
You can then use the value of the index to know which property, defined in names, was called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With