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

es6 class constructor is not invoked #409

Closed
mcharytoniuk opened this issue Mar 28, 2015 · 2 comments
Closed

es6 class constructor is not invoked #409

mcharytoniuk opened this issue Mar 28, 2015 · 2 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@mcharytoniuk
Copy link

I am trying to invoke my React Element but I think that constructor is not invoked. I am using class like this:

"use strict";

var MyManager = require("NativeModules").MyManager,
    React = require("react-native");

class MyElement extends React.Component {
    "constructor"(props) {
        super(props);

        React.AlertIOS("hello", "world");
        this.state = {
            "isSomethingOk": false
        };
    }

    "componentWillMount"() {
        MyManager.onSomethingChanged(isSomethingOk => {
            this.onSomethingChanged(isSomethingOk);
        });
    }

    "onSomethingChanged"(isSomethingOk) {
        this.setState({
            "isSomethingOk": isSomethingOk
        });
    }

    "render"() {
        return <React.View>
            <React.Text>
                {String(this.state.isSomethingOk)}
            </React.Text>
        </React.View>;
    }
};

module.exports = MyElement;

React.AlertIOS("hello", "world"); is never invoked nor initial state is. Are class constructors called during instanciating React Native components?

@vjeux
Copy link
Contributor

vjeux commented Mar 28, 2015

cc @spicyj

@sophiebits
Copy link
Contributor

Looks like we don't transform the constructor correctly if it's quoted. If you just write constructor(props) { perhaps it works? (Is there a reason you're quoting everything?)

Can you file an issue at https://github.com/facebook/jstransform for the transform problem?

@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants