Shopify / react-native-skia

High-performance React Native Graphics using Skia

Home Page:https://shopify.github.io/react-native-skia

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TextAlign in Paragraph maker crashes android

p-sebastian opened this issue · comments

Description

If a TextAlign property is passed to the Paragraph maker it will crash Android

Version

1.2.3

Steps to reproduce

const paragraph = useMemo(() => {
	const { text } = props
	const builder = Skia.ParagraphBuilder.Make({
		textAlign: TextAlign.Center
	})
	builder
		.addText(text)

	return builder.build()
}, [props])

Snack, code example, screenshot, or link to a repository

error thrown

Error while updating prop textAlign
java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String
	at com.facebook.react.uimanager.ViewManagersPropertyCache$StringPropSetter.getValueOrDefault(ViewManagersPropertyCache.java:291)
	at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:111)
	at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:161)
	at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:65)
	at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:321)
	at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:248)
	at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:419)

I was passing the TextAlign enum value as a style property to a normal Text element, which was causing the issue. since it expected a string