masroorejaz / react-simple-captcha

A very simple and powerful captcha for ReactJS
40 stars 19 forks source link

Not able to change the background color of captcha #6

Closed nitesh585 closed 3 years ago

nitesh585 commented 3 years ago

I am creating a function-based react component and loading Enginge inside useEffect method.

  useEffect(() => {
    loadCaptchaEnginge(5, "blue");
  }, []);

But, when I tried to change the background color of the captcha it didn't work.

masroorejaz commented 3 years ago

It will not work in useEffect. Use it in componentDidMount

componentDidMount () { loadCaptchaEnginge((5, "blue"); };

nitesh585 commented 3 years ago

@masroorejaz I have already mentioned that I am creating a function-based component, not a class-based. And, In the docs of react it is clearly mentioned that: If you’re familiar with React class lifecycle methods, you can think of useEffect Hook as componentDidMount, componentDidUpdate, and componentWillUnmount combined.

Then, It should work with useEffect too.

masroorejaz commented 3 years ago

I haven't tested it or work a lot with useEffect.

So really sorry can't help you there.