Reputation: 5123
I have a React app, but I need to run some client side js once the component has finished loading. What is the best way to run js that interacts with the DOM like $('div').mixItUp()
once the render function has finished and loaded. Very new to React so sorry if this is stupidly easy.
Upvotes: 1
Views: 1419
Reputation: 486
Put your code inside the componentDidMount
method on your component. See the documentation on lifecycle methods. With ES6 syntax, this will look like
class MyComponent extends React.Component {
...
componentDidMount() {
$('div').mixItUp();
}
...
}
Upvotes: 6