Skip to content

Image Mapper callbacks unable to access updated state - only access initialized state values #94

Open
@ashahjahan

Description

@ashahjahan

Steps to reproduce

Steps:

  1. Code Sandbox: https://codesandbox.io/p/sandbox/nice-swanson-89lm88?file=%2Fsrc%2FApp.tsx%3A66%2C16
  2. Click on Floor area in Image Map
  3. State updates (check by clicking button), but the alert which access the same state variable "region" does not update in the ImageMapper call back and continues to stay "Initial State".

I have also found another similar error reported by a user here: https://stackoverflow.com/questions/72079850/trouble-setting-state-with-onclick-function-only-with-imagemapper-component-rea

For some reason your Image Mapper callbacks only accesses the initial state value even after the state value has been updated.

Current behavior

For some reason your Image Mapper callbacks only accesses the initial state value even after the state value has been updated.

Expected behavior

Image Mapper callbacks should access the current state values.

Context

No response

Error stack

No response

Live example link

https://codesandbox.io/p/sandbox/nice-swanson-89lm88?file=%2Fsrc%2FApp.tsx%3A66%2C16

Your environment

Desktop

  • OS: Mac
  • Browser: Firefox + Chrome

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is neededquestionA valid question

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions