Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Why is there no lifecycle event for componenDidUpdate? #18

Closed
agenthunt opened this issue Oct 4, 2015 · 2 comments
Closed

Why is there no lifecycle event for componenDidUpdate? #18

agenthunt opened this issue Oct 4, 2015 · 2 comments

Comments

@agenthunt
Copy link

Is there any specific reason, there is no lifecycle event for componenDidUpdate? I have a usecase where I need to find something in the dom after the component has updated ? Any suggestions on how to go about this ?

@pH200
Copy link
Owner

pH200 commented Oct 7, 2015

We do really need a lifecycle event for componentDidMount. However, it might not be that necessary to have a lifecycle event for componentDidUpdate. Because:

  1. You can hook up events in componentDidUpdate for such use cases
  2. There is no componentDidUpdate hook in virtual-dom

Having said that, we still need a lifecycle event for componentDidMount. And it's probably fine having other lifecycle events such as componentDidUpdate as well. I am going to make updates. The API is going to look like this:

const Foo = component('Foo', function (interactions) {
  const componentDidUpdate$ = interactions.get('React_componentDidUpdate')
    .map(refs => {
      const inputElement = React.findDOMNode(refs.refInput);
      // manipulate DOM elements
    });

  return Rx.Observable.just('')
    .merge(componentDidUpdate$)
    .map(value => <input type="text" ref="refInput" />);
}):

@pH200
Copy link
Owner

pH200 commented Dec 10, 2015

Sorry it took me a long time to look back at this issue. We have now supported the component's lifecycles by introducing a new parameter for the component's definition function. Details can be found at Working with React

I'm now closing this issue. Feel free to reopen this if you have any questions. Thanks.

@pH200 pH200 closed this as completed Dec 10, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants