0

I get the following error and cannot seem to find where this error is produced. I just did a site conversion to JSX.

ERROR:

./src/containers/Services.js Syntax error: C:/Users/me/Desktop/backups/react-static/site/src/containers/Services.js: "timerId" is read-only

    <div
        id="sliderNext"
        onClick={() => {
          nextSlide();
          clearTimeout(timerId);
          setTimeout(function tick() {
            nextSlide();
            timerId = setTimeout(tick, 7000); 
          }, 7000); 
         }}
    >

My code.js:

export var timerId = () => {
        setTimeout(function tick() {
            nextSlide();
            timerId = setTimeout(tick, 7000); 
        }, 7000);
    };
isherwood
  • 58,414
  • 16
  • 114
  • 157
user1088793
  • 623
  • 2
  • 9
  • 19
  • Try changing the variable name or the method. I think you are having a collision of var names. – Marco Feb 04 '19 at 16:39
  • `timerId` is first an arrow function, next a setTimeout id, so you basically use the same name for two different things, not a good idea ;) – sjahan Feb 04 '19 at 16:41

0 Answers0