Skip to content

fix: access mapInstance outside of Map component #50

@jinn2u

Description

@jinn2u

hi, first of all I'm big fan of you.
i have little idea in this library

AS-IS
to access map instance, we can use useMapContext
but because of Provider is inside of Map component, map instance is accessible only from child components with the map component as a parent.

const InnerMap = () => {
    const map = useMapContext()
    return (
        ...
    )
}
const NaverMap = () => {
    return (
    <Map
      <InnerMap />
    </Map>
    )
}

TO-BE
how about change usage of useMapContext like this?

index.tsx
<MapContextProvider>
    <App />
</MapContextProvider>

App.tsx

function App() {
  const map = useMapContext();
  return (
    <Map />
  );
}

i'll make pr if you ok.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions