react-native-select-pro icon indicating copy to clipboard operation
react-native-select-pro copied to clipboard

Data does not appear in the dropdown when state is updated

Open hunzalaqamar opened this issue 1 year ago • 2 comments

Describe the bug the data in the dropdown is not being shown after the API call and the usestate gets updated

To Reproduce Steps to reproduce the behavior:

  1. Do any API call and retrieve data in a useState
  2. Pass the getter constant of usestate into the select component
  3. The data will not be shown

Environment (please complete the following information):

  • OS: Android
  • OS Version: Android 13
  • React Native Version : 0.72.4
  • Google Pixel 3

hunzalaqamar avatar Dec 20 '23 18:12 hunzalaqamar

Has this been resolved?

kyagie avatar Mar 10 '24 09:03 kyagie

I didn't check it again but i found a runaround for it. I re-render the component manually everytime the state is updated and that is how I'm able to show new data in it.

On Sun, Mar 10, 2024, 14:32 Arthur Kirabo @.***> wrote:

Has this been resolved?

— Reply to this email directly, view it on GitHub https://github.com/MobileReality/react-native-select-pro/issues/237#issuecomment-1987159489, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQPTZBS4ZQANYUT3JHAEADLYXQSBXAVCNFSM6AAAAABA5HZ5PSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBXGE2TSNBYHE . You are receiving this because you authored the thread.Message ID: @.***>

hunzalaqamar avatar Mar 10 '24 10:03 hunzalaqamar

I'm getting the same behavior. My list of options it's not updating after useEffect changes the state for the list.

jeferandom avatar Jun 03 '24 08:06 jeferandom

This is my code to re-render if helps to anyone facing same issue. Thanks to @hunzalaqamar for the workaround suggestion.

const [renderKey, setRenderKey] = useState(0);

useEffect(() => {

//update my list of options code here
    ...
   
    setRenderKey(prevKey => prevKey + 1);
  }, []);
  
  
  <Select key={renderKey} options={cropsList} theme={"dark"} styles={styles} />

jeferandom avatar Jun 03 '24 08:06 jeferandom

Appreciated @jeferandom

hunzalaqamar avatar Jun 03 '24 22:06 hunzalaqamar

Also having this problem, thank you for the workaround.

0afcode avatar Jun 25 '24 22:06 0afcode

resolved: https://github.com/MobileReality/react-native-select-pro/pull/240

dawidgierdal avatar Jun 28 '24 12:06 dawidgierdal