KonstantinSimeonov / tsx-control-statements

Control flow JSX/TSX elements that get compiled to plain old javascript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not seem to work

Melazeta opened this issue · comments

I've installed this plugin with npm: npm install tsx-control-statements.

I have the following code:

<View>
    <If condition={true}>
        <Text>visible because condition is true</Text>
    </If>
    <If condition={false}>
        <Text>not visible because condition is false</Text>
    </If>
    <Choose>
        <When condition={true}>
            <Text>when</Text>
        </When>
        <Otherwise>
            <Text>otherwise</Text>
        </Otherwise>
    </Choose>
</View>

And in the application every single <Text> is visible, regardless of the condition being true or false or being inside the <Otherwise>.

Am I missing some kind of configuration?

You probably didn't add the typescript transformer to your build configuration. What build tool are you using? Could you provide a link to the repo or an example for your build config?

How do I configure typescript transformer? I'm using Vite.