@@ -35,8 +35,12 @@ type Props = {
3535 redirectPath : ?string ,
3636} ;
3737
38- export class Login extends React . Component < Props > {
39- redirectPath = null ;
38+ type State = {
39+ redirectPath : ?string ,
40+ } ;
41+
42+ export class Login extends React . Component < Props , State > {
43+ state = { redirectPath : null } ;
4044
4145 escape = ( ) => {
4246 this . props . history . push ( `/${ this . props . match . params . communitySlug } ` ) ;
@@ -46,15 +50,15 @@ export class Login extends React.Component<Props> {
4650 const { location, redirectPath } = this . props ;
4751
4852 if ( redirectPath ) {
49- this . redirectPath = redirectPath ;
53+ this . setState ( { redirectPath } ) ;
5054 }
5155
5256 if ( location && ! redirectPath ) {
5357 const searchObj = queryString . parse ( this . props . location . search ) ;
54- this . redirectPath = searchObj . r ;
58+ this . setState ( { redirectPath : searchObj . r } ) ;
5559 }
5660
57- track ( events . LOGIN_PAGE_VIEWED , { redirectPath : this . redirectPath } ) ;
61+ track ( events . LOGIN_PAGE_VIEWED , { redirectPath : this . state . redirectPath } ) ;
5862 }
5963
6064 render ( ) {
@@ -63,6 +67,7 @@ export class Login extends React.Component<Props> {
6367 isLoading,
6468 match,
6569 } = this . props ;
70+ const { redirectPath } = this . state ;
6671
6772 if ( community && community . id ) {
6873 const { brandedLogin } = community ;
@@ -89,8 +94,7 @@ export class Login extends React.Component<Props> {
8994
9095 < LoginButtonSet
9196 redirectPath = {
92- this . redirectPath ||
93- `${ CLIENT_URL } /${ match . params . communitySlug } `
97+ redirectPath || `${ CLIENT_URL } /${ match . params . communitySlug } `
9498 }
9599 signinType = { 'signin' }
96100 />
0 commit comments