Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ return <HCaptcha ref={captchaRef} onLoad={onLoad} sitekey={sitekey} {...props} /
|`imghost`|String|No|`-`|See enterprise docs.|
|`reportapi`|String|No|`-`|See enterprise docs.|
|`sentry`|Boolean|No|`true`|See enterprise docs.|
|`userJourneys`|Boolean|No|`false`|See enterprise docs.|
|`secureApi`|Boolean|No|`-`|See enterprise docs.|
|`scriptSource`|String|No|`-`|See enterprise docs.|
| `cleanup` | Boolean | No | `true` | Remove script tag after setup.|
Expand Down
1 change: 1 addition & 0 deletions demo/app/examples/ClassExample.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class ClassExample extends React.Component {
onError={this.handleError}
onChalExpired={this.handleChallengeExpired}
sentry={false}
userJourneys={true}
/>
<div style={{ display: 'flex', paddingTop: '8px', gap: '8px' }}>
<button onClick={this.handleThemeChange}>Change theme</button>
Expand Down
14 changes: 11 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class HCaptcha extends React.Component {
scriptSource,
secureApi,
cleanup = true,
userJourneys,
} = this.props;
const mountParams = {
render: 'explicit',
Expand All @@ -147,7 +148,8 @@ class HCaptcha extends React.Component {
scriptLocation,
scriptSource,
secureApi,
cleanup
cleanup,
userJourneys
};

hCaptchaLoader(mountParams)
Expand All @@ -167,16 +169,22 @@ class HCaptcha extends React.Component {
// • Component has already been mounted
if (!isApiReady || captchaId) return;

// It is needed to pass only the props that hCaptcha supports
// React are able to receive userJourneys as prop but hCaptcha not
// hcaptcha expects to have only "uj" parameter to enable user journeys
const { userJourneys, ...basicProps } = this.props;

const renderParams = Object.assign({
"open-callback" : this.handleOpen,
"close-callback" : this.handleClose,
"error-callback" : this.handleError,
"chalexpired-callback": this.handleChallengeExpired,
"expired-callback" : this.handleExpire,
"callback" : this.handleSubmit,
}, this.props, {
}, basicProps, {
hl: this.props.hl || this.props.languageOverride,
languageOverride: undefined
languageOverride: undefined,
uj: userJourneys !== undefined ? userJourneys : false,
});

const hcaptcha = this._hcaptcha;
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface HCaptchaProps {
loadAsync?: boolean;
scriptLocation?: HTMLElement | null;
sentry?: boolean;
userJourneys?: boolean;
cleanup?: boolean;
custom?: boolean;
secureApi?: boolean;
Expand Down
Loading