Skip to content

globalClassNamePolyfill removes properties #192

Description

@doits

Before submitting a new issue

  • I tested using the latest version of the library, as the bug might be already fixed.
  • I tested using a supported version of react native.
  • I checked for possible duplicate issues, with possible answers.

Bug summary

When using globalClassNamePolyfill: true, due to the way it works, properties get lost. For example Image has a resolveAssetPath function as a property which gets lost.

Without the polyfill enabled you can do this and it imports the function:

import { resolveAssetPath } from Image

With the polyfill enabled, it doesn't work anymore (the above returns undefined).

I think the solution might be to do a Object.assign:

export function Image(props: StyledProps<ImageProps, typeof mapping>) {
  return useCssElement(RNImage, props, mapping);
}

Object.assign(Image, RNImage)

Library version

3.0.0

Environment info

Not relevant

Steps to reproduce

See above

Reproducible example repository

Not provided

Activity

  1. doits commented on Sep 26, 2025

    @doits
    Author

    Some more info/context:

    • Polyfill disabled:

      import { Image } from "react-native";
      
      console.log(Object.keys(Image));
      // => ["displayName", "getSize", "getSizeWithHeaders", "prefetch", "prefetchWithMetadata", "queryCache", "resolveAssetSource"]
    • Polyfill enabled:

      import { Image } from "react-native";
      
      console.log(Object.keys(Image));
      // => []

    I found it out because it breaks https://github.com/react-native-webview/react-native-webview, which depends on this.

  2. marklawlor commented on Oct 1, 2025

    @marklawlor
    Contributor

    Fixed in 7f3eb1f

  3. doits commented on Oct 1, 2025

    @doits
    Author

    Thanks, looks good! Will test out when a new version is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions