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(os): fix unavailable mapView on initialization #3477

Merged
merged 1 commit into from
May 7, 2024

Conversation

mfazekas
Copy link
Contributor

@mfazekas mfazekas commented May 7, 2024

Fixes: https://github.com/rnmapbox/sponsors/issues/4

Repo, thanks much: @benjamin-sweney

import React, { useEffect, useRef } from 'react';
import { View } from 'react-native';
import { MapView } from '@rnmapbox/maps';

const Example = () => {
  const ref = useRef(null);

  useEffect(() => {
    const check = async () => {
      const center = await ref.current?.getCenter();

      console.log(center);
    };

    setTimeout(check, 1000);
  }, []);

  return (
    <View style={{ flex: 1, justifyContent: 'center' }}>
      <MapView
        ref={ref}
        zoomEnabled={false}
        scrollEnabled={false}
        scaleBarEnabled={false}
        style={{ height: 400 }}
      />
    </View>
  );
};

export default Example;

@mfazekas mfazekas changed the title ios: fix unavailable mapView on initialization fix(os): fix unavailable mapView on initialization May 7, 2024
@mfazekas mfazekas merged commit 9a9bc35 into main May 7, 2024
10 checks passed
@mfazekas mfazekas deleted the fix-mapView-access-before-init branch May 7, 2024 13:50
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

Successfully merging this pull request may close these issues.

None yet

1 participant