react-native-radial-gradient icon indicating copy to clipboard operation
react-native-radial-gradient copied to clipboard

Center should be passed as {x: 0, y: 0} otherwise it won't update

Open bimusiek opened this issue 4 years ago • 5 comments

On iOS, if you pass center as [0, 0] and dynamically update it to other value, it won't be updated. As on native side, it is recognised as CGPoint (not NSArray) thus React will not trigger setter for this property if it is not x,y;

bimusiek avatar Apr 08 '21 13:04 bimusiek

Facing the same issue

oguzhnatly avatar Jun 12 '21 18:06 oguzhnatly

@oguzhnatly You can use our fork

bimusiek avatar Jun 14 '21 08:06 bimusiek

@oguzhnatly Sorry, we did not make a PR nor fork for this. However in the code you can simply make an HOC with

  const convertedCenter = useMemo(() => {
    return !center || Platform.OS !== 'ios' ? center : { x: center[0], y: center[1] };
  }, [center]);

bimusiek avatar Jun 17 '21 10:06 bimusiek

Thanks @bimusiek!

oguzhnatly avatar Jun 17 '21 10:06 oguzhnatly

I've tried passing it as {x: 0, y: 0} yet I get "Property is not configurable" error. However, passing it as an array also has no effect at all no matter what numbers I pass. Is it completely broken or am I missing something obvious here?

(iOS 16.2, RN 0.71.4)

canpoyrazoglu avatar Apr 02 '23 03:04 canpoyrazoglu