Skip to content
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

fix: access mapInstance outside of Map component #50

Open
jinn2u opened this issue Sep 14, 2023 · 1 comment
Open

fix: access mapInstance outside of Map component #50

jinn2u opened this issue Sep 14, 2023 · 1 comment

Comments

@jinn2u
Copy link

jinn2u commented Sep 14, 2023

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.

@josworks27
Copy link
Member

I agree with your idea. And I want you to contribute to this project.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants