react-google-recaptcha icon indicating copy to clipboard operation
react-google-recaptcha copied to clipboard

Question: How to skip checking on development (or conditionally)?

Open abdulmahamaliyev opened this issue 3 years ago • 3 comments

Like what's the cleanest way to disable it during development or staging?

Something like: <form onSubmit={onSubmitWithReCAPTCHA}> <ReCAPTCHA ref={recaptchaRef} size="invisible" sitekey="Your client site key" skip={process.env.NODE_ENV !== 'production'} /> </form>

react-google-recaptcha version: 2.1.0

abdulmahamaliyev avatar Oct 02 '22 15:10 abdulmahamaliyev

Have a try of the code below? {'development' === process.env.NODE_ENV && <ReCAPTCHA />}

henrycechen avatar Nov 08 '22 06:11 henrycechen

I don't understand how that's supposed to work. can you show a full example?

abdulmahamaliyev avatar Nov 08 '22 06:11 abdulmahamaliyev

My bad. Assume you're using function components function myFun() { // ... return( <> { 'development' === process.env.NODE_ENV && <ReCAPTCHA />} </> ) } It's called conditional rendering, here's the reference to the official doc https://reactjs.org/docs/conditional-rendering.html

henrycechen avatar Nov 08 '22 07:11 henrycechen