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

App crashes during render when formattedString uses embedded JavaScript in JSX #66

Open
ujwal-setlur opened this issue Oct 25, 2020 · 3 comments

Comments

@ujwal-setlur
Copy link

export function First({ navigation }: FirstScreenProps) {
    const message = `Boo Hoo!` // Referencing this below in JSX crashes!
    function onButtonTap() {
        navigation.navigate('second');
    }
    return (
        <gridLayout
            width={"100%"}
            height={"100%"}
            rows={"*, auto, auto, *"}
            columns={"*, 200, *"}
        >
            <label
                row={1}
                col={1}
                className="info"
                textAlignment={"center"}
                fontSize={24}
            >
                <formattedString>
                    <span className="fas" text="&#xf135;" />
                    <span> {message} </span> <---- THIS CRASHES
                </formattedString>
            </label>
            <button
                row={2}
                col={1}
                fontSize={24}
                textAlignment={"center"}
                onTap={() => Dialogs.alert("Tap received!")}
            >
                Tap me for an alert
            </button>
            <button onTap={onButtonTap} fontSize={24} text={"Go to next screen"} />
        </gridLayout>
    );
}
@shirakaba
Copy link
Owner

I believe this is rather due to not supporting text nodes as children of <span> (as we found over Slack that using the text property instead gets it to work).

It looks like it used to work: https://react-nativescript.netlify.app/docs/components/label, so I wonder what's caused the regression. I'll look into it next time.

@Lelelo1
Copy link

Lelelo1 commented Nov 2, 2020

Does<span>my text</span> also crashes or is it just <span>{myTextVar}</span>?

@shirakaba
Copy link
Owner

shirakaba commented Nov 3, 2020

@Lelelo1 I haven’t checked, but I would guess both – both should lead to the text content being passed into React.createElement as children (rather than as the “text” prop).

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

3 participants