Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Current React lifecycle methods problem #54

Open
@mtscrb

Description

@mtscrb

I've been trying to "fix a bug" when using react-integration with skatejs components.
I found what is the problem but I'm not sure how to solve it properly. If anyone have any idea / feedback on this I will appreciate it.

You can see the issue here.

So, if you take a look at the console, that button is rendered once without / with missing values and a second time with all the needed properties.

That MAY cause some weird behaviour (in my case, my component flashes when it is instantiated with attributes that changes a default style applied previously).

If you don't use react-integration it won't happen. So digging a bit inside react-integration I found that lifecycle methods in react don't work in sync with skate's or at least that is my assumption.

Trying to make this message not too long, the sequence I see is:

  1. Render
    Initial render, that create a react component with only style prop. This is to avoid dynamically computed properties using get and set
    ->
  2. componentDidMount
    ->
  3. componentWillReceiveProps (called explicitly in componentDidMount) This callback adds all the attributes to the current node, where node is the result of ReactDOM.findDOMNode(this) ( see here ). That will trigger another render in skatejs, but not in the tests (look at the props tests if you are interested) because tests are not using skatejs components only native custom elements.

Naturally I will think of this sequence to be:
componentWillMount (call componentWillReceiveProps)
->
componentWillReceiveProps Here it should set all props in the node
->
render at this point everything should be in place

The problem is, you cannot access findDOMNode in componentWillReceiveProps to add all the properties, so this approach I guess is not possible.

Will be looking forward to any ideas / feedback / correction on any wrong information that I may have written.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions