I am trying to migrate a React component, written outside of Meteor, to run inside Meteor. I posted this question also on [StackOverflow][1]
The problem I have is that jQuery ($) is not defined. I fully understand that the use of jQuery is not necessary in a lot of cases and is even frowned upon within React. That being said, Meteor currently installs jQuery by default. Being able to use jQuery for animations will help me overcome a limitation of React’s ReactTransitionGroup and ReactCSSTransitionGroup components. I can not simply add a link to jQuery CDN because that would cause jQuery to be loaded twice! Once from the CDN and once inside Meteor.
My problem is that I don’t know how to access Meteor’s jQuery from within a React component.
Here is a snippet of one of my components:
componentWillReceiveProps: function(nextProps) {
if (nextProps.slideDirection !== this.props.slideDirection) {
this.setState({ slideDirection: nextProps.slideDirection })
var $el = $(this.getDOMNode());
if (nextProps.slideDirection.trim() === 'down') { console.log('= down'); } else { console.log('!= down'); }
switch (nextProps.slideDirection.trim()) {
case 'up':
$el.slideUp('animationDuration: 400');
break;
case 'down':
$el.slideDown('animationDuration: 400');
break;
default:
}
}
},
I have really struggled with this all weekend. I “really” want to be able to use jQuery in this case for the animation effect. I am trying to animate the DIV height expansion along with visibility of the body text. This is easily achieved with jQuery’s slideup and slidedown. Any help is much appreciated!
[1]: http://stackoverflow.com/questions/33087644/meteor-react-component-unable-to-reference-jquery