Skip to content

[Bug / Feature Request] withUniwind maps JSON props (e.g. customMapStyle) as style objects, breaking non-style props #452

Description

@dacoto

What happened?

Description

When using withUniwind to wrap third-party components that accept JSON props that are not style objects, the HOC incorrectly attempts to process or interfere with those props as part of its style mapping pipeline.

A concrete example is react-native-maps / expo-maps MapView, which accepts a customMapStyle prop of type Array<MapStyleElement> (a Google Maps style JSON array). When the component is wrapped with withUniwind, customMapStyle either gets stripped, overwritten, or corrupted — making it impossible to apply a custom map style.

Expected Behavior

customMapStyle should be forwarded as-is to the underlying MapView component, since it is not a style prop — it's a domain-specific JSON prop used by the Google Maps SDK.

Actual Behavior

customMapStyle is not forwarded correctly to the native component. The map renders without the custom style applied.

Root Cause (hypothesis)

withUniwind appears to apply style resolution or prop transformation to all props that look like objects/arrays, without a way to opt certain props out of this pipeline.

Feature Request

Please add a mechanism to exclude specific props from being processed by withUniwind. For example:

const StyledMapView = withUniwind(MapView, {
  // existing prop mappings...
}, {
  excludeProps: ['customMapStyle', 'region', 'initialRegion'],
})

Or alternatively, a more granular passthrough option:

const StyledMapView = withUniwind(MapView, {
  customMapStyle: { passthrough: true },
})

This would ensure that props listed in excludeProps (or marked as passthrough) are forwarded to the wrapped component without any transformation.

Context

  • Library: react-native-maps / expo-maps
  • Prop affected: customMapStyle (Array<MapStyleElement> — Google Maps style JSON)
  • Uniwind version: [your version]
  • React Native / Expo version: [your version]

Workaround (temporary)

As a workaround, the raw component can be used without wrapping and the style prop applied manually:

<MapView
  style={resolvedStyles}
  customMapStyle={mapStyle}
/>

But this defeats the purpose of using Uniwind.

Steps to Reproduce

New expo project with react-native-maps or expo-maps and Styled MapView with custom customMapStyle

import MapView from 'react-native-maps'
import { withUniwind } from 'uniwind'

const StyledMapView = withUniwind(MapView)

// customMapStyle is a standard Google Maps style JSON array
<StyledMapView
  className="flex-1"
  customMapStyle={[
    {
      elementType: 'geometry',
      stylers: [{ color: '#212121' }],
    },
    // ...
  ]}
/>

Snack or Repository Link

https://github.com/dacoto/expo-uniwind-maps

Uniwind version

1.0.0-rc.5 (pro)

React Native Version

0.83.2

Platforms

Android

Expo

Yes

Additional information

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    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