Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

theme dark/light not changing while changing prop #296

Open
HiImAndre opened this issue Aug 30, 2024 · 1 comment
Open

theme dark/light not changing while changing prop #296

HiImAndre opened this issue Aug 30, 2024 · 1 comment

Comments

@HiImAndre
Copy link

"react-google-recaptcha": "^3.1.0",

<ReCAPTCHA
  hidden={isDev}
  sitekey={globals.recaptcha.siteKey}
  onChange={onChange}
  theme={darkMode ? "dark" : "light"} // doesn't change on prop change
/>

when darkMode is changing, the prop applies to it but recaptcha gui stays the the same color until proper site refresh.

@emrebal98
Copy link

You can use key prop to re-render.

const theme = darkMode ? "dark" : "light";

<ReCAPTCHA
  key={theme}
  hidden={isDev}
  sitekey={globals.recaptcha.siteKey}
  onChange={onChange}
  theme={theme} 
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants