mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 09:08:07 -05:00
Guard calls to componentDidMount with a check for existence.
Fix tag on username step.
This commit is contained in:
parent
30967a3056
commit
c77db39062
7 changed files with 19 additions and 7 deletions
|
@ -55,8 +55,10 @@ class BirthDateStep extends React.Component {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
|
if (this.props.sendAnalytics) {
|
||||||
this.props.sendAnalytics('join-birthdate');
|
this.props.sendAnalytics('join-birthdate');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
validateSelect (selection) {
|
validateSelect (selection) {
|
||||||
if (selection === 'null') {
|
if (selection === 'null') {
|
||||||
|
|
|
@ -23,7 +23,9 @@ class CountryStep extends React.Component {
|
||||||
this.countryOptions = [];
|
this.countryOptions = [];
|
||||||
}
|
}
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
|
if (this.props.sendAnalytics) {
|
||||||
this.props.sendAnalytics('join-country');
|
this.props.sendAnalytics('join-country');
|
||||||
|
}
|
||||||
this.setCountryOptions();
|
this.setCountryOptions();
|
||||||
}
|
}
|
||||||
setCountryOptions () {
|
setCountryOptions () {
|
||||||
|
|
|
@ -35,7 +35,9 @@ class EmailStep extends React.Component {
|
||||||
this.emailRemoteCache = {};
|
this.emailRemoteCache = {};
|
||||||
}
|
}
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
|
if (this.props.sendAnalytics) {
|
||||||
this.props.sendAnalytics('join-email');
|
this.props.sendAnalytics('join-email');
|
||||||
|
}
|
||||||
// automatically start with focus on username field
|
// automatically start with focus on username field
|
||||||
if (this.emailInput) this.emailInput.focus();
|
if (this.emailInput) this.emailInput.focus();
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,10 @@ class GenderStep extends React.Component {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
|
if (this.props.sendAnalytics) {
|
||||||
this.props.sendAnalytics('join-gender');
|
this.props.sendAnalytics('join-gender');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
handleSetCustomRef (customInputRef) {
|
handleSetCustomRef (customInputRef) {
|
||||||
this.customInput = customInputRef;
|
this.customInput = customInputRef;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,10 @@ class RegistrationErrorStep extends React.Component {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
|
if (this.props.sendAnalytics) {
|
||||||
this.props.sendAnalytics('join-error');
|
this.props.sendAnalytics('join-error');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
handleSubmit (e) {
|
handleSubmit (e) {
|
||||||
// JoinFlowStep includes a <form> that handles a submit action.
|
// JoinFlowStep includes a <form> that handles a submit action.
|
||||||
// But here, we're not really submitting, so we need to prevent
|
// But here, we're not really submitting, so we need to prevent
|
||||||
|
|
|
@ -40,7 +40,9 @@ class UsernameStep extends React.Component {
|
||||||
// Send info to analytics when we aren't on the standalone page.
|
// Send info to analytics when we aren't on the standalone page.
|
||||||
// If we are on the standalone join page, the page load will take care of this.
|
// If we are on the standalone join page, the page load will take care of this.
|
||||||
if (!window.location.pathname.includes('/join')) {
|
if (!window.location.pathname.includes('/join')) {
|
||||||
this.props.sendAnalytics('join-email');
|
if (this.props.sendAnalytics) {
|
||||||
|
this.props.sendAnalytics('join-username-modal');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// automatically start with focus on username field
|
// automatically start with focus on username field
|
||||||
|
|
|
@ -80,7 +80,7 @@ describe('UsernameStep test', () => {
|
||||||
<UsernameStep
|
<UsernameStep
|
||||||
sendAnalytics={sendAnalyticsFn}
|
sendAnalytics={sendAnalyticsFn}
|
||||||
/>);
|
/>);
|
||||||
expect(sendAnalyticsFn).toHaveBeenCalledWith('join-email');
|
expect(sendAnalyticsFn).toHaveBeenCalledWith('join-username-modal');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('handleValidSubmit passes formData to next step', () => {
|
test('handleValidSubmit passes formData to next step', () => {
|
||||||
|
|
Loading…
Reference in a new issue