haxe-react / react-native

React Native externs for Haxe
61 stars 9 forks source link

Using external jsx instead of inline one #14

Closed varadig closed 7 years ago

varadig commented 7 years ago

I wanted to use external jsx for instead of inline, with compiletime macro:


class Main {
    public static function main() {
        AppRegistry.registerComponent('TestReactNative', function() return App);

    }
}
@:expose('App')
class App extends ReactComponent{
    function new(props) {

        super(props);

        state = {
            scene: 0
        }
    }

    override function render() {
        function goto(i) setState({scene: i});
        return switch state.scene {
            default:
                jsx(CompileTime.readFile("jsx/Home.jsx"));
        }
    }
}

Home.jsx:

<WebView
    source={{uri: 'https://github.com/facebook/react-native'}}
    style={{marginTop: 20}}
>

</WebView>

but I got this error when compile:

/usr/local/lib/haxe/std/haxe/macro/ExprTools.hx:289: characters 11-16 : Unsupported expression: { expr => ECall({ expr => EField({ expr => EConst(CIdent(CompileTime)), pos => #pos(src/Main.hx:35: characters 20-31) },interpolateFile), pos => #pos(src/Main.hx:35: characters 20-47) },[{ expr => EConst(CString(jsx/Home.jsx)), pos => #pos(src/Main.hx:35: characters 48-62) }]), pos => #pos(src/Main.hx:35: characters 20-63) }
/Volumes/Work/develop/hx/libs/react/git/src/lib/react/ReactMacro.hx:27: characters 19-43 : Called from
src/Main.hx:35: characters 16-64 : Called from

How can I use external jsx with RNhaxe, if I can?

thanks

kevinresol commented 7 years ago

The jsx macro isn't defined in this library, please report the issue at https://github.com/massiveinteractive/haxe-react.