maplibre / maplibre-react-native

A MapLibre react native module for creating custom maps
Other
215 stars 52 forks source link

Warning: MarkerView: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead. #430

Closed Pieeer1 closed 2 days ago

Pieeer1 commented 1 month ago

Steps to Trigger Behavior

  1. Create a new MapLibreGL.MapView 2.. Add a MarkerView with coordinates
  2. Build and run the application. you will receive the warning.

Link to Minimal Reproducible Example

        <View style={styles.container}>
         <MapLibreGL.MapView
            ref={mapRef}
            style={styles.map} 
            logoEnabled={false} 
            styleURL={mapUri + token}
            rotateEnabled={false}
            zoomEnabled={true}
         >
            <MapLibreGL.Camera
            zoomLevel={2}
            centerCoordinate={[defaultView?.longitude ?? 0, defaultView?.latitude ?? 0]}
            />
            { shipment?.shipmentStops.map((x, i) => {
            return (
                <MarkerView key={i} coordinate={[x.location?.longitude ?? 0, x.location?.latitude ?? 0]}>
                    <View style={{backgroundColor: 'red', width: 10, height: 10, borderRadius: 5}}></View>
                </MarkerView>
                )
            })}

            <RippleButton iconName="mode-of-travel" iconSize={25} onPress={() => setIsLiveView(!isLiveView)} color="#000000" ></RippleButton>
         </MapLibreGL.MapView>
        </View>

Expected Behavior

No Warning

Actual Behavior

Warning

Screenshots (if applicable)

image

Version(s) affected

Additional context

RobertSasak commented 1 month ago

Observations

React it deprecating defaultProps in function component. https://github.com/facebook/react/pull/25699 https://github.com/facebook/react/blob/main/CHANGELOG.md#1830-april-25-2024

MarkerView is such a component https://github.com/maplibre/maplibre-react-native/blob/9fcf6d162b49044a3789eadc5c1d4b784444728d/javascript/components/MarkerView.tsx#L56