-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] Change the confusing markerState parameter position
to a clear name.
#637
Comments
…o `initialPosition`. googlemaps#637
Personally I'd be in favor of eliminating |
That is an interesting proposition. Admittedly, I have had issues with the
way it works as well. Might be worth investigating as a possibility.
…On Wed, Oct 16, 2024, 15:14 Uli Bubenheimer ***@***.***> wrote:
Personally I'd be in favor of eliminating rememberMarkerState entirely. I
find it misleading and an anti-pattern:
https://dev.to/bubenheimer/effective-map-composables-non-draggable-markers-2b2#:~:text=Be%20aware%20that,recommend%20ignoring%20it
.
https://dev.to/bubenheimer/effective-map-composables-draggable-markers-3bea#:~:text=This%20behavior%20is,with%20a%20model
.
—
Reply to this email directly, view it on GitHub
<#637 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA2GLJ4EXEB2OMQF6IVYXLZ3X73ZAVCNFSM6AAAAABQATZMWGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJVHAZDAOJZGM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Yes, it can be confusing. Not only me, but my coworkers are also confused. Line 150 in f7f4854
@Composable
fun rememberUpdatedMarkerState(position: LatLng): MarkerState =
// This pattern is equivalent to what rememberUpdatedState() does:
// rememberUpdatedState() uses MutableState, we use MarkerState.
// This is more efficient than updating position in an effect,
// as we avoid an additional recomposition.
remember { MarkerState(position = position) }.also {
it.position = position
} The example code included in this repository also creates and uses #638 |
…o `initialPosition`. googlemaps#637
MarkerState
hasrememberMarkerState
for use in compose.But looking at the example above, it's easy to get confused.
This is because there is a risk of misunderstanding that the value entered as a parameter to remember (
position
in this case) acts as a key that is automatically reflected when the value changes.I also had a hard time because the position wasn't updated.
To avoid this misunderstanding, compose foundation libraries add an
inital
prefix to rememberXXX functions.So my suggestion is to change the name from
position
toinitialPosition
to reduce confusion.It seems like a simple fix, I'll create a PR. Please review it.
Thanks!
The text was updated successfully, but these errors were encountered: