- I'm getting this error around both the "var" definition inside the event listener. Vs code suggests to add { and , again and again but nothing gets fixed.
- Also Vs code suggests me to use '{'>'}' instead of =>
React code->
import React from 'react';
class Event extends React.Component{
render(){
return(
<div>
<div class=" ">
<svg>
<g>
< path d=/>
</g>
...
</svg>
</div>
<script>
...
</script>
</div>
);
}
}
export default Event;
following is the script->
let path = document.querySelector ('path')
let pathLength = path.getTotalLength()
path.style.strokeDasharray = pathLength + ' ' + pathlength;
path.style.strokeDashoffset = pathLength;
//I get error for "=>" in the following
window.addEventListener('scroll',() => {
//I get errors for both of these vars
var scrollPercentage =(document.documentElement.scrollTop+document.body.scrollTop)/(document.documentElement.scrollHeight-document.documentElement.clientHeight)
var drawLength = pathLength*scrollPercentage
path.style.strokeDashoffset = pathLength-drawLength
})
</script>
Following is the app.js->
import Event from './pages/events';
import './App.css';
function App() {
return (
<>
<Event/>
</>
);
}
export default App;