hxf31891 / react-gradient-color-picker

An easy to use color/gradient picker for React.js
MIT License
147 stars 49 forks source link

selectedPoint and deletePoint no longer working in v=2.0.21 #28

Closed maxwelllharper closed 2 years ago

maxwelllharper commented 2 years ago

It would seem that 'selectedPoint' and 'deletePoint' is no longer working in v=2.0.21

The 'selectedPoint' only returns a 0 no matter which point is selected. And even when a 0 is passed into deletePoint() it returns an error saying "A gradient must have at least 2 colors, disable your delete button..." image

-- The trash-can 'delete point' that's part of the component's inherent controls still works though.

hxf31891 commented 2 years ago

Hey @Refractive-Strategy, thank you for pointing this out. Would you please post a screenshot of your code, specifically where you initially declare the useColorPicker hook. i.e. const { selectedPoint } = useCol...

I believe that you may have forgotten to pass in the value & callback. The correct syntax is: const { selectedPoint, deletePoint } = useColorPicker(value, callback)

maxwelllharper commented 2 years ago

image

maxwelllharper commented 2 years ago

OK: FIXED with your hint. Thank you,

EXPLANATION: We implemented a state saving structure/flow that has us saving this state outside of this component and in fact to an external API... I have now passed the proper value, and callback. It seems to be working properly now.

image