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(android, Camera): remove ts and add CameraModule instead of setNativeProps #3376

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

mfazekas
Copy link
Contributor

@mfazekas mfazekas commented Feb 14, 2024

The following component can be used to reproduce the issue. Basically each button should affect the camera, but camera should not reapply for the re-render button.

import React from 'react';
import { Button } from 'react-native';
import { MapView, ShapeSource, LineLayer, Camera } from '@rnmapbox/maps';

const NY = [-74.00597, 40.71427];

class BugReportExample extends React.Component {
  state = {
    center: NY,
    count: 0,
  };
  ref = React.createRef();

  render() {
    return (
      <>
        <Button
          title="Prop: move longitude"
          onPress={() =>
            this.setState({ center: [this.state.center[0] + 0.01, 40.71427] })
          }
        />
        <Button
          title="Fly: move longitude"
          onPress={() =>
            this.ref.current.flyTo([
              this.state.center[0] + 0.05,
              this.state.center[1],
            ])
          }
        />
        <Button
          title="Prop: NY"
          onPress={() => this.setState({ center: NY })}
        />
        <Button
          title="Prop: new Array(...NY)"
          onPress={() => this.setState({ center: new Array(...NY) })}
        />
        <Button
          title={`Re-render: ${this.state.count}`}
          onPress={() => this.setState({ count: this.state.count + 1 })}
        />
        <MapView style={{ flex: 1 }}>
          <Camera
            centerCoordinate={this.state.center}
            zoomLevel={14}
            ref={this.ref}
          />
        </MapView>
      </>
    );
  }
}

export default BugReportExample;

@mfazekas mfazekas force-pushed the mfazekas/camera-remove-set-native-props branch from 851b0a0 to eedae05 Compare February 14, 2024 11:23
@mfazekas mfazekas merged commit b90fe4b into main Feb 14, 2024
10 checks passed
@mfazekas mfazekas deleted the mfazekas/camera-remove-set-native-props branch February 14, 2024 12:17
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.

1 participant