Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the following error #2

Open
oferRounds opened this issue Oct 5, 2023 · 8 comments
Open

Getting the following error #2

oferRounds opened this issue Oct 5, 2023 · 8 comments

Comments

@oferRounds
Copy link

Any idea?

image
@oferRounds
Copy link
Author

I mean, I understand it fails to initialize the text component, but why?

@Ahmedhamed77
Copy link

Ahmedhamed77 commented Oct 6, 2023

same problem here RCTText
Invariant Violation: View config getter callback for component RCTTextmust be a function (receivedundefined).

so as mentioned here
https://x.com/fernandotherojo/status/1710255820573651129?s=46&t=K_3BKXza1sRkpPmebjAPUw
we can use it directly from nativeText component

@oferRounds
Copy link
Author

And that will work? Can you post the example here?

@Ahmedhamed77
Copy link

yes it works fine without any errors

import React from 'react';
import {TextProps} from 'react-native';
import {NativeText} from 'react-native/Libraries/Text/TextNativeComponent';

export interface FastTextProps
  extends Omit<
    TextProps,
    | 'onPress'
    | 'onPressIn'
    | 'onPressOut'
    | 'onLongPress'
    | 'pressRetentionOffset'
  > {}

const FastText: React.FC<FastTextProps> = props => {
  return <NativeText {...props} />;
};

export {FastText};

and in the declrations.d.ts

declare module 'react-native/Libraries/Text/TextNativeComponent' {
  import {TextProps} from 'react-native';

  export interface NativeTextProps extends TextProps {
    isHighlighted?: boolean;
    selectionColor?: any;
    onClick?: (event: any) => void;
    isPressable?: boolean;
  }

  export const NativeText: React.ComponentType<NativeTextProps>;
  export const NativeVirtualText: React.ComponentType<NativeTextProps>;
}

for selectionColor and onClick they have another type but I just made it any for now

@oferRounds
Copy link
Author

And the NativeText import is equivalent to createElement("RCTText", props);?

@peterpme
Copy link
Owner

peterpme commented Oct 7, 2023

Thank you @Ahmedhamed77, making this update now!

@MartianH
Copy link

MartianH commented Oct 8, 2023

And the NativeText import is equivalent to createElement("RCTText", props);?

@oferRounds For all intent and purposes, yes it is. See export at line 71, in TextNativeComponent.js

// ./react-native/Libraries/Text/TextNativeComponent.js

export const NativeText: HostComponent<NativeTextProps> =
  (createReactNativeComponentClass('RCTText', () =>
    createViewConfig(textViewConfig),
  ): any);

@efstathiosntonas
Copy link

efstathiosntonas commented Jan 5, 2024

@Ahmedhamed77 @peterpme do you have any idea if onClick works only on web?

@github-staff github-staff deleted a comment from simonspg May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@efstathiosntonas @peterpme @oferRounds @MartianH @Ahmedhamed77 and others