react-native-paper icon indicating copy to clipboard operation
react-native-paper copied to clipboard

Undefined color from MaterialCommunityIcon

Open Izocel opened this issue 6 months ago • 13 comments

Image

Patch file:

diff --git a/node_modules/react-native-paper/lib/module/components/MaterialCommunityIcon.js b/node_modules/react-native-paper/lib/module/components/MaterialCommunityIcon.js
index 472fee1..523fac9 100644
--- a/node_modules/react-native-paper/lib/module/components/MaterialCommunityIcon.js
+++ b/node_modules/react-native-paper/lib/module/components/MaterialCommunityIcon.js
@@ -1,7 +1,6 @@
 function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
 import * as React from 'react';
-import { StyleSheet, Text, Platform } from 'react-native';
-import { black } from '../styles/themes/v2/colors';
+import { Platform, StyleSheet, Text } from 'react-native';
 export const accessibilityProps = Platform.OS === 'web' ? {
   role: 'img',
   focusable: false
@@ -55,7 +54,7 @@ const MaterialCommunityIcons = IconModule || FallbackIcon;
  */
 const DefaultIcon = ({
   name,
-  color = black,
+  color = "black",
   size,
   direction,
   allowFontScaling,

Izocel avatar May 15 '25 10:05 Izocel

Hey! Thanks for opening the issue. Can you provide a minimal repro which demonstrates the issue? Posting a snippet of your code in the issue is useful, but it's not usually straightforward to run. A repro will help us debug the issue faster. Please try to keep the repro as small as possible. The easiest way to provide a repro is on snack.expo.dev. If it's not possible to repro it on snack.expo.dev, then you can also provide the repro in a GitHub repository.

github-actions[bot] avatar May 15 '25 10:05 github-actions[bot]

Any update on this ? This is blocking us

abhilmp avatar May 15 '25 19:05 abhilmp

@abhilmp could you please add a repro?

lukewalczak avatar May 19 '25 09:05 lukewalczak

any update ?

mohammedshameelvk avatar May 20 '25 12:05 mohammedshameelvk

Hi @mohammedshameelvk, could you please describe the steps to reproduce the issue?

lukewalczak avatar May 20 '25 12:05 lukewalczak

@lukewalczak when i am using button from react-native-paper it show the error :

ROR Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run yarn or npm install., js engine: hermes ERROR Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run yarn or npm install., js engine: hermes ERROR Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run yarn or npm install., js engine: hermes ERROR Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run yarn or npm install., js engine: hermes ERROR TypeError: Cannot read property 'jsx' of undefined

It point into materialCommunityIcon

mohammedshameelvk avatar May 21 '25 05:05 mohammedshameelvk

I'm not able to reproduce it on the fresh project nor on the expo snack. Please attach the minimal repro in a GitHub repository which demonstrates the issue.

lukewalczak avatar May 21 '25 08:05 lukewalczak

@lukewalczak i am using react native cli "react-native-paper": "^5.14.5", "react-native-paper-dates": "^0.18.27", "react-native-safe-area-context": "^4.6.3", "react-native-screens": "4.0.0",

mohammedshameelvk avatar May 21 '25 09:05 mohammedshameelvk

Did you install icons library as specified in documentation:

Image

lukewalczak avatar May 21 '25 18:05 lukewalczak

I am already using this package But now I am getting the issue TypeError: 0, _$$_REQUIRE(_dependencyMap[7], "react/jsx-runtime").jsx is not a function (it is undefined)

Image

mohammedshameelvk avatar May 22 '25 04:05 mohammedshameelvk

I was also getting this undefined color variable error. What I ended up doing to fix it is making sure to spread the default theme and colors before providing my own coloring theme that gets passed into the paper provider to make sure nothing was missed. Snippet below is from the paper theming docs.

import * as React from 'react'; import { MD3LightTheme as DefaultTheme, PaperProvider, } from 'react-native-paper'; import App from './src/App';

const theme = { ...DefaultTheme, // Specify custom property myOwnProperty: true, // Specify custom property in nested object colors: { ...DefaultTheme.colors, }, };

I'm not sure why that black variable in the icon is not being recognized, but if you provide your own defaults in the theme it never seems to need it and provides a patchless way of fixing the problem.

kcropp78 avatar May 22 '25 16:05 kcropp78

@lukewalczak any update?

mohammedshameelvk avatar May 27 '25 11:05 mohammedshameelvk

I am so facing this issues could please share any solution for this

Murugeswari avatar Jun 12 '25 08:06 Murugeswari

Facing same issue.

Pls share any solution for this....

Akash-Gupta-V2STech avatar Jun 23 '25 12:06 Akash-Gupta-V2STech

@mohammedshameelvk

have you find any solution for the below issue

"TypeError: 0, _$$_REQUIRE(_dependencyMap[7], "react/jsx-runtime").jsx is not a function (it is undefined)"

Akash-Gupta-V2STech avatar Jun 23 '25 12:06 Akash-Gupta-V2STech

Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it.

github-actions[bot] avatar Jul 24 '25 02:07 github-actions[bot]