img-mapper / react-img-mapper

React Component to highlight interactive zones in images
https://img-mapper.github.io/react-docs
MIT License
122 stars 39 forks source link

Type '{ name: string; areas: string; }' is not assignable to type 'Map' #60

Closed jasymons closed 1 year ago

jasymons commented 1 year ago

Describe the bug There's an error on the map parameter of the ImageMapper component: "Type '{ name: string; areas: string; }' is not assignable to type 'Map'. Types of property 'areas' are incompatible. Type 'string' is not assignable to type 'MapAreas[]'."

To Reproduce Use <ImageMapper src{URL} map={MAP} /> with the example JSON from the npm page: https://raw.githubusercontent.com/img-mapper/react-docs/master/src/assets/example.json

Error Stack Type '{ name: string; areas: string; }' is not assignable to type 'Map'. Types of property 'areas' are incompatible. Type 'string' is not assignable to type 'MapAreas[]'.

Expected behavior Map should work

Screenshots Screenshot 2023-02-28 at 15 51 22

Desktop (please complete the following information):

NishargShah commented 1 year ago

Hello @jasymons, areas is JSON and you need to copy it from the example.json and paste it there

Sample Codesandbox: https://codesandbox.io/s/spring-monad-vyfltk?file=/src/App.js

Please check the docs: https://img-mapper.github.io/react-docs/?path=/story/examples-simple--simple

image