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

onPress feedback #68

Closed
uladkasach opened this issue Sep 5, 2019 · 3 comments
Closed

onPress feedback #68

uladkasach opened this issue Sep 5, 2019 · 3 comments

Comments

@uladkasach
Copy link

it would be great to be able to provide some sort of onPress feedback for the user.

one option could be having a renderComponent method, similar to a renderText method, to overwrite the default. Usage could be as follows:


  private renderComponent = (text, onPress) => {
    return <TouchableOpacity onPress={onPress}>{text}x</TouchableOpacity>; // or whatever other touchable response component user wants to use, e.g., react-native-material-ripple
  };

  public render() {
    const { children } = this.props;
    return (
      <ParsedText
        selectable={this.props.selectable}
        style={{
          color: Colors.text.primary,
          fontSize: 16,
        }}
        parse={[
          { type: 'url', style: clickableStyle, onPress: this.handleUrlPress, renderComponent: this.renderComponent },
          { type: 'phone', style: clickableStyle, onPress: this.handlePhonePress, renderComponent: this.renderComponent },
          { type: 'email', style: clickableStyle, onPress: this.handleEmailPress, renderComponent: this.renderComponent },
        ]}
        childrenProps={{ allowFontScaling: false }}
      >
        {children}
      </ParsedText>
@fbartho
Copy link
Contributor

fbartho commented Jun 11, 2020

This is an interesting idea @uladkasach.

One problem, however is that many components (including Image) are not allowed to be nested inside of a Text Component on some platform.

If you still want this, I'd be happy to review an appropriate PR. It is not however high priority for me to implement this myself at this time.

If you don't want this, please let me know so we can close this ticket. Thanks!

If you find a bug or have a PR, I'm working on a new release in #79

@fbartho
Copy link
Contributor

fbartho commented Jun 11, 2020

I'm going to close this ticket in favor of the older #37 -- please feel free to comment back if we should reopen this!

@fbartho fbartho closed this as completed Jun 11, 2020
@unknwngera
Copy link

@fbartho hi, is this lib still maintaining? i think this prop (renderComponent) could accept at least a text component to overwrite the default, eg i have my custom text component with special logic inside

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

No branches or pull requests

3 participants