Skip to content

[Bug]: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://react.dev/link/unsafe-component-lifecycles for details. #3885

@Sechorda

Description

@Sechorda

Mapbox Implementation

Mapbox

Mapbox Version

11.0

React Native Version

0.79.3

Platform

Android

@rnmapbox/maps version

10.1.38
edit: Still in 10.1.41

Standalone component to reproduce

import React from 'react';
import { View } from 'react-native';
import MapboxGL from '@rnmapbox/maps';

// Note: In a real bug report, the token should be configurable or documented
MapboxGL.setAccessToken('your-mapbox-token-here');

const MinimalMapBugRepro = () => {
  return (
    <View style={{ flex: 1 }}>
      <MapboxGL.MapView
        style={{ flex: 1 }}
        styleURL="mapbox://styles/mapbox/streets-v11"
      >
        <MapboxGL.Camera
          zoomLevel={14}
          centerCoordinate={[-74.00597, 40.71427]} // NYC coordinates
        />
      </MapboxGL.MapView>
    </View>
  );
};

export default MinimalMapBugRepro;

Observed behavior and steps to reproduce

When calling .MapView when using (SDK 53) this error is produced:

Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://react.dev/link/unsafe-component-lifecycles for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://react.dev/link/derived-state

Please update the following components: %s MapView

The offending file/call is at

node_modules/@rnmapbox/maps/src/components/MapView

cat MapView.tsx | grep "component"

  • [iOS, mapbox (v10) implementation only] A string referencing an image key. Requires an Images component.
    componentDidMount() {
    componentWillUnmount() {
    UNSAFE_componentWillReceiveProps(nextProps: Props) {

Expected behavior

No error should be produced regarding StrictMode recommendations

Notes / preliminary analysis

No response

Additional links and references

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🪲Something isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions