0

I have a question following this post:

issue

How should I use a jQuery plugin that modify the DOM with react. Like jimfb kindly answered to me on GH, React shoud return a pre-rendered component. So my question is, how exaclty call a function like remodal() in my example, during the lifecycle of a component?

ciaoben
  • 3,138
  • 4
  • 27
  • 42
  • From the discussion on GH I understand that you should put the dialog on the render function and show or display it manually, so create your own dialog implementation or put dialog outside the react application. I like the first option more, but it is just a tastes thing – Raulucco Jun 29 '15 at 08:58

1 Answers1

0

I suggest you to read my answer here: Why should addChangeListener be in componentDidMount instead of componentWillMount?

But basically, when you need to integrate some existing plugin or code with React, the painless way is to generally call that code on the componentDidMount method and do the event listening the old way. If you are with jQuery, that means you should use something like

$(this.getDOMNode()).find('.some-child').on('click', this.onChildClick)

By doing it this way, you will miss some of the most important features regarding event delegation in React (see https://facebook.github.io/react/docs/interactivity-and-dynamic-uis.html#under-the-hood-autobinding-and-event-delegation) but that should not be a problem unless you wanted to create hundreds of event listeners.

Community
  • 1
  • 1
damianmr
  • 2,511
  • 1
  • 15
  • 15