Skip to content

ThumbImage not applied when using compiled JS, works with TS source #734

@pingkai

Description

@pingkai

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Description:
When using the compiled JS version of @react-native-community/slider, the thumbImage prop does not get applied on iOS, even when provided. Using the TS source code directly works as expected.

Steps to reproduce:
1. Use the JS build of the slider in a React Native project on iOS.
2. Pass thumbImage={require('transparent.png')}.
3. Observe that the thumb image is not set, and the setter in native code is never called.
4. Replace the JS import with the TS source code. The thumb image is applied correctly.

Expected behaviour:
thumbImage should work correctly in the JS build, just like the TS source.

Environment:
• React Native: [0.79.6]
• @react-native-community/slider: 5.0.1
• iOS: 26.0

Notes:
• The problem seems related to the build/compilation logic in the JS bundle, possibly the way conditional assignment is optimized.
• Using TS source bypasses the issue.

Today I used patch-package to patch @react-native-community/slider@5.0.1 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@react-native-community/slider/package.json b/node_modules/@react-native-community/slider/package.json
index 19bd73b..3f34810 100644
--- a/node_modules/@react-native-community/slider/package.json
+++ b/node_modules/@react-native-community/slider/package.json
@@ -8,8 +8,7 @@
   "publishConfig": {
     "access": "public"
   },
-  "main": "dist/Slider.js",
-  "types": "typings/index.d.ts",
+  "main": "src/Slider.tsx",
   "keywords": [
     "react-native",
     "react native",

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug reportSomething isn't workingduplicateThis issue or pull request already existsplatform: iOSIssue related to iOS platform

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions