'How fix remember in Jetpack Compose?
Solution 1:[1]
Why do you want to remember the input dates? You already have them in the composable param input.
You are getting different output because value in input has changed and has triggered recomposition, while in startDate and endDate you already have rememebered state from previous recomposition. On the next recomposition, the remember block won't be called, because the result already exists in the cache of the composer.
Here is what you need to improve in this code:
- Remember the formatter, it's being recreated each recomposition.
- Don't remember the
starDateandendDatefrominputobject - Format the dates only once, and remember that result instead, in case something else triggeres the recomposition.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nikola Despotoski |

