-
Notifications
You must be signed in to change notification settings - Fork 59
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
Class constructor is run after render method on component #116
Comments
Hmmm this makes sense, I hadn't realized that the transform-class-properties plugin would need to bind functions after the constructor. The thing is that That's why the component has already been rendered after |
By the way in react this is not an issue because components don't render themselves. |
Yeah, another option is to have a separate render function that can receive a component to render, like React. |
Hey guys, so I went with a compromise here that I think will work well. I kept the default behavior for component constructors, rendering the component automatically. For simple use cases people will still be able to create and render the component with a single call. I've created a new way to render components though, through static functions. You can now use There's also the option of using the We can make this the only way to render components in the future if desired, but I preferred keeping the old way for now, so that it's not always required to import So it should be possible to use transform-class-properties now, as long as you render through these functions :) |
Would be ideal to merge, the |
They already use the same signature, and people can just use |
What I meant is the same method and same signature, avoiding two different render methods. |
I would suggest to keep |
The thing is that At the same time I don't think we should keep only |
Understood. The suggested approach could be a proxied |
We've talked more about this and though it's possible to have a single function for both these cases, it would require either a new repo or much more complex code, so we decided to continue with both functions. The only difference is that @eduardolundgren suggested moving from Again, the only difference between the two functions is that |
In our project we were hoping to use transform-class-properties . We need this to avoid having to
.bind(this)
over and over. If we utilize class properties, we are able to use arrow functions in our class for those methods.However, we realized that transform-class-properties doesn't work with metal components. While I was debugging this I realized that constructor was being called after created and render. See example below.
Ideally we want to be able to call
this.boundFunction
in render.Does this sound right? Is there a reason why the constructor would be called after render?
The text was updated successfully, but these errors were encountered: