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

make part of text2 clickable! #557

Open
hamzafarooq-10P opened this issue Nov 5, 2024 · 1 comment
Open

make part of text2 clickable! #557

hamzafarooq-10P opened this issue Nov 5, 2024 · 1 comment

Comments

@hamzafarooq-10P
Copy link

I have encountered a problem where i want to make some part of text2 prop pressable, like a hyperlink.

I was wondering if there is any way to achieve?

Simulator Screenshot - iPhone 16 Pro - 2024-11-05 at 12 37 07

@bvechiato
Copy link

You can do this by creating your custom toast.

For example,

export const toastConfig = {
	clickableToast: ({ text1, text2, props }) => (
	    <View>
	      <Text>{text1}</Text>
	      <Text onPress={props.onPressText2}>{text2}</Text>
	    </View>
	  )
}

Or

export const toastConfig = {
	clickableToast: ({ text1, text2, props }) => (
	    <View>
	      <Text>{text1}</Text>
	      <Text>{text2}</Text>
	
	      {props.buttonText && props.handleClick && (
	        <TouchableOpacity onPress={props.handleClick}>
	          <Text>{props.buttonText}</Text>
	        </TouchableOpacity>
	      )}
	    </View>
	  )
}

Then, when you want to show it

Toast.show({
	type: "clickableToast",
	text1: "",
	text2: "",
	props: {
		// onPressText2: () => {}
		buttonText: "",
		handleClick: () => {},
	}
})

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

2 participants