August August - 2 months ago 17
React JSX Question

.velocity is not a function

Head :

<!-- Velocity -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.2.3/velocity.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.2.3/velocity.ui.min.js"></script>

<!-- React -->
<script src = "https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.js"></script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js"></script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/react-router/2.7.0/ReactRouter.js"></script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/superagent/2.2.0/superagent.js"></script>


Velocity is included by
let velocity = window.Velocity


If i try to
console.log(velocity)
it shows a function,if i console log
document.getElementById("menu)
it shows an element,however when i try to run
document.getElementById("menu).velocity("slideDown", { duration: 1500 });
after my component is rendered console says


Uncaught TypeError: dbyId(...).velocity is not a function


What could be the reason for this happening?I am using babel transformer with php back-end,no requires or imports are happening.

Answer

If you don't use jQuery you need to use

Velocity(document.getElementById("menu"), { opacity: 0.5 });

since velocity don't add stuff to element prototype.