ReactJs OldPage stays at the bottom after redirecting to a new Page









up vote
0
down vote

favorite












after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.






import React, Component from 'react';
import Button, Container, Form, FormGroup, Label, Input, Row, Col from 'reactstrap';
import NavLink from 'reactstrap';
import register from '../actions/auth';
import Redirect from 'react-router-dom';
import connect from 'react-redux';

class registerForm extends Component
constructor(props)
super(props);
this.state =
modal: false,
nestedModal: false,
closeAll: false,
email: '',
password: '',

redirect: false,

confirmPassword:'',
registerEmail: '',
registerPassword: '',
firstName:'',
lastName:'',
address:'',
city:'',
state:'',
zipcode:'',
phoneNumber:'',
user: ,
isLoggedIn: false
;



static getDerivedStateFromProps(props, state)
if (props.user !== state.user)
return
...state,
user: props.user
;

return null;


userRegister (e)
e.preventDefault();
this.props.register(
email: this.state.registerEmail,
password: this.state.registerPassword,
name: this.state.firstName + ' ' + this.state.lastName,
address:this.state.address + ' ' + this.state.city + ' ' + this.state.state + ' ' + this.state.zipcode,
city:this.state.city,
state:this.state.state,
zipcode:this.state.zipcode,
confirmPassword: this.state.confirmPassword,
phoneNumber: this.state.phoneNumber
);
this.setState(
modal: !this.state.modal,
redirect: true
);


renderRedirect = () =>
if(this.state.redirect)
return <Redirect to ="/"/>




handleChange = event =>
this.setState(
[event.target.name]: event.target.value
);



toggleNested()
this.setState(
nestedModal: !this.state.nestedModal,
closeAll: false
);


toggleAll()
this.setState(
nestedModal: !this.state.nestedModal,
closeAll: true
);





render()
return (
<div>
<Container>
<Form className = "login-body">
<Row>
<Col s=12>
<FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
<Label for="exampleRegEmail">Email:</Label>
<Input type="email" name="registerEmail" value=this.state.registerEmail onChange=this.handleChange.bind(this) id='exampleRegEmail' placeholder="name@gmail.com" />
</FormGroup>
</Col>
</Row>
<Row>
<Col s=12>
<FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
<Label for="exampleRegPassword">Password:</Label>
<Input type="password" name="registerPassword" value=this.state.registerPassword onChange=this.handleChange.bind(this) id='exampleRegPassword' placeholder="password" />
</FormGroup>
</Col>
</Row>
<Row>
<Col s=12>
<FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
<Label for="exampleRegPassword">Confirm Password:</Label>
<Input type="password" name="confirmPassword" value=this.state.confirmPassword onChange=this.handleChange.bind(this) id='exampleComPassword' placeholder="password" />


</FormGroup>
</Col>
</Row>

<Row>
<Col >
<FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
<Label for="exampleFirstName"> First Name: </Label>
<Input type="text" name="firstName" value=this.state.firstName onChange=this.handleChange.bind(this) id='exampleFirstName' placeholder="Elizabeth" />
</FormGroup>
</Col>

<Col >
<FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

<Label for="exampleLastName"> Last Name: </Label>
<Input type="text" name="lastName" value=this.state.lastName onChange=this.handleChange.bind(this) id='exampleLastName' placeholder="Swann"/>


</FormGroup>
</Col>
</Row>

<Row>
<Col>

<FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
<Label for="exampleAddress"> Address: </Label>
<Input type="text" name="address" value=this.state.address onChange=this.handleChange.bind(this) id='exampleAddress' placeholder="1 Washington Square"/>


</FormGroup>
</Col>
</Row>

<Row>
<Col xs="6" sm="4">
<FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

<Label for="exampleCity"> City: </Label>
<Input type="text" name="city" value=this.state.city onChange=this.handleChange.bind(this) id='exampleCity' placeholder="San Jose"/>



</FormGroup>
</Col>
<Col xs="6" sm="4">
<FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

<Label for="exampleState"> State: </Label>
<Input type="text" name="state" value=this.state.state onChange=this.handleChange.bind(this) id='exampleState' placeholder="CA"/>

</FormGroup>
</Col>

<Col sm="4">
<FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

<Label for="exampleCity"> Zip Code: </Label>
<Input type="text" name="zipcode" value=this.state.zipcode onChange=this.handleChange.bind(this) id='exampleZipCode' placeholder="95112"/>
</FormGroup>
</Col>
</Row>
<Row>
<Col s=12>
<FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
<Label for="exampleState"> Phone Number: </Label>
<Input type="text" name="phoneNumber" value=this.state.phoneNumber onChange=this.handleChange.bind(this) id='examplePhoneNumber' placeholder="408-123-4553"/>
</FormGroup>
</Col>
</Row>
<FormGroup check>
<Label check className="term-condition">
<Input type="checkbox"/>' '

By creating this account, you agree to our <Button className="term-condition-button">Terms & Condintions</Button>

</Label>
</FormGroup>
</Form>

<Button color="info" onClick=this.userRegister.bind(this)>Submit</Button>' '
this.renderRedirect()

</Container>
</div>
);



export default connect(null, register)(registerForm)





Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.










share|improve this question

























    up vote
    0
    down vote

    favorite












    after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.






    import React, Component from 'react';
    import Button, Container, Form, FormGroup, Label, Input, Row, Col from 'reactstrap';
    import NavLink from 'reactstrap';
    import register from '../actions/auth';
    import Redirect from 'react-router-dom';
    import connect from 'react-redux';

    class registerForm extends Component
    constructor(props)
    super(props);
    this.state =
    modal: false,
    nestedModal: false,
    closeAll: false,
    email: '',
    password: '',

    redirect: false,

    confirmPassword:'',
    registerEmail: '',
    registerPassword: '',
    firstName:'',
    lastName:'',
    address:'',
    city:'',
    state:'',
    zipcode:'',
    phoneNumber:'',
    user: ,
    isLoggedIn: false
    ;



    static getDerivedStateFromProps(props, state)
    if (props.user !== state.user)
    return
    ...state,
    user: props.user
    ;

    return null;


    userRegister (e)
    e.preventDefault();
    this.props.register(
    email: this.state.registerEmail,
    password: this.state.registerPassword,
    name: this.state.firstName + ' ' + this.state.lastName,
    address:this.state.address + ' ' + this.state.city + ' ' + this.state.state + ' ' + this.state.zipcode,
    city:this.state.city,
    state:this.state.state,
    zipcode:this.state.zipcode,
    confirmPassword: this.state.confirmPassword,
    phoneNumber: this.state.phoneNumber
    );
    this.setState(
    modal: !this.state.modal,
    redirect: true
    );


    renderRedirect = () =>
    if(this.state.redirect)
    return <Redirect to ="/"/>




    handleChange = event =>
    this.setState(
    [event.target.name]: event.target.value
    );



    toggleNested()
    this.setState(
    nestedModal: !this.state.nestedModal,
    closeAll: false
    );


    toggleAll()
    this.setState(
    nestedModal: !this.state.nestedModal,
    closeAll: true
    );





    render()
    return (
    <div>
    <Container>
    <Form className = "login-body">
    <Row>
    <Col s=12>
    <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
    <Label for="exampleRegEmail">Email:</Label>
    <Input type="email" name="registerEmail" value=this.state.registerEmail onChange=this.handleChange.bind(this) id='exampleRegEmail' placeholder="name@gmail.com" />
    </FormGroup>
    </Col>
    </Row>
    <Row>
    <Col s=12>
    <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
    <Label for="exampleRegPassword">Password:</Label>
    <Input type="password" name="registerPassword" value=this.state.registerPassword onChange=this.handleChange.bind(this) id='exampleRegPassword' placeholder="password" />
    </FormGroup>
    </Col>
    </Row>
    <Row>
    <Col s=12>
    <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
    <Label for="exampleRegPassword">Confirm Password:</Label>
    <Input type="password" name="confirmPassword" value=this.state.confirmPassword onChange=this.handleChange.bind(this) id='exampleComPassword' placeholder="password" />


    </FormGroup>
    </Col>
    </Row>

    <Row>
    <Col >
    <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
    <Label for="exampleFirstName"> First Name: </Label>
    <Input type="text" name="firstName" value=this.state.firstName onChange=this.handleChange.bind(this) id='exampleFirstName' placeholder="Elizabeth" />
    </FormGroup>
    </Col>

    <Col >
    <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

    <Label for="exampleLastName"> Last Name: </Label>
    <Input type="text" name="lastName" value=this.state.lastName onChange=this.handleChange.bind(this) id='exampleLastName' placeholder="Swann"/>


    </FormGroup>
    </Col>
    </Row>

    <Row>
    <Col>

    <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
    <Label for="exampleAddress"> Address: </Label>
    <Input type="text" name="address" value=this.state.address onChange=this.handleChange.bind(this) id='exampleAddress' placeholder="1 Washington Square"/>


    </FormGroup>
    </Col>
    </Row>

    <Row>
    <Col xs="6" sm="4">
    <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

    <Label for="exampleCity"> City: </Label>
    <Input type="text" name="city" value=this.state.city onChange=this.handleChange.bind(this) id='exampleCity' placeholder="San Jose"/>



    </FormGroup>
    </Col>
    <Col xs="6" sm="4">
    <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

    <Label for="exampleState"> State: </Label>
    <Input type="text" name="state" value=this.state.state onChange=this.handleChange.bind(this) id='exampleState' placeholder="CA"/>

    </FormGroup>
    </Col>

    <Col sm="4">
    <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

    <Label for="exampleCity"> Zip Code: </Label>
    <Input type="text" name="zipcode" value=this.state.zipcode onChange=this.handleChange.bind(this) id='exampleZipCode' placeholder="95112"/>
    </FormGroup>
    </Col>
    </Row>
    <Row>
    <Col s=12>
    <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
    <Label for="exampleState"> Phone Number: </Label>
    <Input type="text" name="phoneNumber" value=this.state.phoneNumber onChange=this.handleChange.bind(this) id='examplePhoneNumber' placeholder="408-123-4553"/>
    </FormGroup>
    </Col>
    </Row>
    <FormGroup check>
    <Label check className="term-condition">
    <Input type="checkbox"/>' '

    By creating this account, you agree to our <Button className="term-condition-button">Terms & Condintions</Button>

    </Label>
    </FormGroup>
    </Form>

    <Button color="info" onClick=this.userRegister.bind(this)>Submit</Button>' '
    this.renderRedirect()

    </Container>
    </div>
    );



    export default connect(null, register)(registerForm)





    Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.






      import React, Component from 'react';
      import Button, Container, Form, FormGroup, Label, Input, Row, Col from 'reactstrap';
      import NavLink from 'reactstrap';
      import register from '../actions/auth';
      import Redirect from 'react-router-dom';
      import connect from 'react-redux';

      class registerForm extends Component
      constructor(props)
      super(props);
      this.state =
      modal: false,
      nestedModal: false,
      closeAll: false,
      email: '',
      password: '',

      redirect: false,

      confirmPassword:'',
      registerEmail: '',
      registerPassword: '',
      firstName:'',
      lastName:'',
      address:'',
      city:'',
      state:'',
      zipcode:'',
      phoneNumber:'',
      user: ,
      isLoggedIn: false
      ;



      static getDerivedStateFromProps(props, state)
      if (props.user !== state.user)
      return
      ...state,
      user: props.user
      ;

      return null;


      userRegister (e)
      e.preventDefault();
      this.props.register(
      email: this.state.registerEmail,
      password: this.state.registerPassword,
      name: this.state.firstName + ' ' + this.state.lastName,
      address:this.state.address + ' ' + this.state.city + ' ' + this.state.state + ' ' + this.state.zipcode,
      city:this.state.city,
      state:this.state.state,
      zipcode:this.state.zipcode,
      confirmPassword: this.state.confirmPassword,
      phoneNumber: this.state.phoneNumber
      );
      this.setState(
      modal: !this.state.modal,
      redirect: true
      );


      renderRedirect = () =>
      if(this.state.redirect)
      return <Redirect to ="/"/>




      handleChange = event =>
      this.setState(
      [event.target.name]: event.target.value
      );



      toggleNested()
      this.setState(
      nestedModal: !this.state.nestedModal,
      closeAll: false
      );


      toggleAll()
      this.setState(
      nestedModal: !this.state.nestedModal,
      closeAll: true
      );





      render()
      return (
      <div>
      <Container>
      <Form className = "login-body">
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegEmail">Email:</Label>
      <Input type="email" name="registerEmail" value=this.state.registerEmail onChange=this.handleChange.bind(this) id='exampleRegEmail' placeholder="name@gmail.com" />
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegPassword">Password:</Label>
      <Input type="password" name="registerPassword" value=this.state.registerPassword onChange=this.handleChange.bind(this) id='exampleRegPassword' placeholder="password" />
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegPassword">Confirm Password:</Label>
      <Input type="password" name="confirmPassword" value=this.state.confirmPassword onChange=this.handleChange.bind(this) id='exampleComPassword' placeholder="password" />


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col >
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleFirstName"> First Name: </Label>
      <Input type="text" name="firstName" value=this.state.firstName onChange=this.handleChange.bind(this) id='exampleFirstName' placeholder="Elizabeth" />
      </FormGroup>
      </Col>

      <Col >
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleLastName"> Last Name: </Label>
      <Input type="text" name="lastName" value=this.state.lastName onChange=this.handleChange.bind(this) id='exampleLastName' placeholder="Swann"/>


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col>

      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleAddress"> Address: </Label>
      <Input type="text" name="address" value=this.state.address onChange=this.handleChange.bind(this) id='exampleAddress' placeholder="1 Washington Square"/>


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col xs="6" sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleCity"> City: </Label>
      <Input type="text" name="city" value=this.state.city onChange=this.handleChange.bind(this) id='exampleCity' placeholder="San Jose"/>



      </FormGroup>
      </Col>
      <Col xs="6" sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleState"> State: </Label>
      <Input type="text" name="state" value=this.state.state onChange=this.handleChange.bind(this) id='exampleState' placeholder="CA"/>

      </FormGroup>
      </Col>

      <Col sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleCity"> Zip Code: </Label>
      <Input type="text" name="zipcode" value=this.state.zipcode onChange=this.handleChange.bind(this) id='exampleZipCode' placeholder="95112"/>
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleState"> Phone Number: </Label>
      <Input type="text" name="phoneNumber" value=this.state.phoneNumber onChange=this.handleChange.bind(this) id='examplePhoneNumber' placeholder="408-123-4553"/>
      </FormGroup>
      </Col>
      </Row>
      <FormGroup check>
      <Label check className="term-condition">
      <Input type="checkbox"/>' '

      By creating this account, you agree to our <Button className="term-condition-button">Terms & Condintions</Button>

      </Label>
      </FormGroup>
      </Form>

      <Button color="info" onClick=this.userRegister.bind(this)>Submit</Button>' '
      this.renderRedirect()

      </Container>
      </div>
      );



      export default connect(null, register)(registerForm)





      Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.










      share|improve this question













      after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.






      import React, Component from 'react';
      import Button, Container, Form, FormGroup, Label, Input, Row, Col from 'reactstrap';
      import NavLink from 'reactstrap';
      import register from '../actions/auth';
      import Redirect from 'react-router-dom';
      import connect from 'react-redux';

      class registerForm extends Component
      constructor(props)
      super(props);
      this.state =
      modal: false,
      nestedModal: false,
      closeAll: false,
      email: '',
      password: '',

      redirect: false,

      confirmPassword:'',
      registerEmail: '',
      registerPassword: '',
      firstName:'',
      lastName:'',
      address:'',
      city:'',
      state:'',
      zipcode:'',
      phoneNumber:'',
      user: ,
      isLoggedIn: false
      ;



      static getDerivedStateFromProps(props, state)
      if (props.user !== state.user)
      return
      ...state,
      user: props.user
      ;

      return null;


      userRegister (e)
      e.preventDefault();
      this.props.register(
      email: this.state.registerEmail,
      password: this.state.registerPassword,
      name: this.state.firstName + ' ' + this.state.lastName,
      address:this.state.address + ' ' + this.state.city + ' ' + this.state.state + ' ' + this.state.zipcode,
      city:this.state.city,
      state:this.state.state,
      zipcode:this.state.zipcode,
      confirmPassword: this.state.confirmPassword,
      phoneNumber: this.state.phoneNumber
      );
      this.setState(
      modal: !this.state.modal,
      redirect: true
      );


      renderRedirect = () =>
      if(this.state.redirect)
      return <Redirect to ="/"/>




      handleChange = event =>
      this.setState(
      [event.target.name]: event.target.value
      );



      toggleNested()
      this.setState(
      nestedModal: !this.state.nestedModal,
      closeAll: false
      );


      toggleAll()
      this.setState(
      nestedModal: !this.state.nestedModal,
      closeAll: true
      );





      render()
      return (
      <div>
      <Container>
      <Form className = "login-body">
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegEmail">Email:</Label>
      <Input type="email" name="registerEmail" value=this.state.registerEmail onChange=this.handleChange.bind(this) id='exampleRegEmail' placeholder="name@gmail.com" />
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegPassword">Password:</Label>
      <Input type="password" name="registerPassword" value=this.state.registerPassword onChange=this.handleChange.bind(this) id='exampleRegPassword' placeholder="password" />
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegPassword">Confirm Password:</Label>
      <Input type="password" name="confirmPassword" value=this.state.confirmPassword onChange=this.handleChange.bind(this) id='exampleComPassword' placeholder="password" />


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col >
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleFirstName"> First Name: </Label>
      <Input type="text" name="firstName" value=this.state.firstName onChange=this.handleChange.bind(this) id='exampleFirstName' placeholder="Elizabeth" />
      </FormGroup>
      </Col>

      <Col >
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleLastName"> Last Name: </Label>
      <Input type="text" name="lastName" value=this.state.lastName onChange=this.handleChange.bind(this) id='exampleLastName' placeholder="Swann"/>


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col>

      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleAddress"> Address: </Label>
      <Input type="text" name="address" value=this.state.address onChange=this.handleChange.bind(this) id='exampleAddress' placeholder="1 Washington Square"/>


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col xs="6" sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleCity"> City: </Label>
      <Input type="text" name="city" value=this.state.city onChange=this.handleChange.bind(this) id='exampleCity' placeholder="San Jose"/>



      </FormGroup>
      </Col>
      <Col xs="6" sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleState"> State: </Label>
      <Input type="text" name="state" value=this.state.state onChange=this.handleChange.bind(this) id='exampleState' placeholder="CA"/>

      </FormGroup>
      </Col>

      <Col sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleCity"> Zip Code: </Label>
      <Input type="text" name="zipcode" value=this.state.zipcode onChange=this.handleChange.bind(this) id='exampleZipCode' placeholder="95112"/>
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleState"> Phone Number: </Label>
      <Input type="text" name="phoneNumber" value=this.state.phoneNumber onChange=this.handleChange.bind(this) id='examplePhoneNumber' placeholder="408-123-4553"/>
      </FormGroup>
      </Col>
      </Row>
      <FormGroup check>
      <Label check className="term-condition">
      <Input type="checkbox"/>' '

      By creating this account, you agree to our <Button className="term-condition-button">Terms & Condintions</Button>

      </Label>
      </FormGroup>
      </Form>

      <Button color="info" onClick=this.userRegister.bind(this)>Submit</Button>' '
      this.renderRedirect()

      </Container>
      </div>
      );



      export default connect(null, register)(registerForm)





      Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.Hello, after submitting the form, the form stays at the bottom while redirecting to the homepage. I cannot figure it out. Any ideas are welcome thanks.






      import React, Component from 'react';
      import Button, Container, Form, FormGroup, Label, Input, Row, Col from 'reactstrap';
      import NavLink from 'reactstrap';
      import register from '../actions/auth';
      import Redirect from 'react-router-dom';
      import connect from 'react-redux';

      class registerForm extends Component
      constructor(props)
      super(props);
      this.state =
      modal: false,
      nestedModal: false,
      closeAll: false,
      email: '',
      password: '',

      redirect: false,

      confirmPassword:'',
      registerEmail: '',
      registerPassword: '',
      firstName:'',
      lastName:'',
      address:'',
      city:'',
      state:'',
      zipcode:'',
      phoneNumber:'',
      user: ,
      isLoggedIn: false
      ;



      static getDerivedStateFromProps(props, state)
      if (props.user !== state.user)
      return
      ...state,
      user: props.user
      ;

      return null;


      userRegister (e)
      e.preventDefault();
      this.props.register(
      email: this.state.registerEmail,
      password: this.state.registerPassword,
      name: this.state.firstName + ' ' + this.state.lastName,
      address:this.state.address + ' ' + this.state.city + ' ' + this.state.state + ' ' + this.state.zipcode,
      city:this.state.city,
      state:this.state.state,
      zipcode:this.state.zipcode,
      confirmPassword: this.state.confirmPassword,
      phoneNumber: this.state.phoneNumber
      );
      this.setState(
      modal: !this.state.modal,
      redirect: true
      );


      renderRedirect = () =>
      if(this.state.redirect)
      return <Redirect to ="/"/>




      handleChange = event =>
      this.setState(
      [event.target.name]: event.target.value
      );



      toggleNested()
      this.setState(
      nestedModal: !this.state.nestedModal,
      closeAll: false
      );


      toggleAll()
      this.setState(
      nestedModal: !this.state.nestedModal,
      closeAll: true
      );





      render()
      return (
      <div>
      <Container>
      <Form className = "login-body">
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegEmail">Email:</Label>
      <Input type="email" name="registerEmail" value=this.state.registerEmail onChange=this.handleChange.bind(this) id='exampleRegEmail' placeholder="name@gmail.com" />
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegPassword">Password:</Label>
      <Input type="password" name="registerPassword" value=this.state.registerPassword onChange=this.handleChange.bind(this) id='exampleRegPassword' placeholder="password" />
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegPassword">Confirm Password:</Label>
      <Input type="password" name="confirmPassword" value=this.state.confirmPassword onChange=this.handleChange.bind(this) id='exampleComPassword' placeholder="password" />


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col >
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleFirstName"> First Name: </Label>
      <Input type="text" name="firstName" value=this.state.firstName onChange=this.handleChange.bind(this) id='exampleFirstName' placeholder="Elizabeth" />
      </FormGroup>
      </Col>

      <Col >
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleLastName"> Last Name: </Label>
      <Input type="text" name="lastName" value=this.state.lastName onChange=this.handleChange.bind(this) id='exampleLastName' placeholder="Swann"/>


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col>

      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleAddress"> Address: </Label>
      <Input type="text" name="address" value=this.state.address onChange=this.handleChange.bind(this) id='exampleAddress' placeholder="1 Washington Square"/>


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col xs="6" sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleCity"> City: </Label>
      <Input type="text" name="city" value=this.state.city onChange=this.handleChange.bind(this) id='exampleCity' placeholder="San Jose"/>



      </FormGroup>
      </Col>
      <Col xs="6" sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleState"> State: </Label>
      <Input type="text" name="state" value=this.state.state onChange=this.handleChange.bind(this) id='exampleState' placeholder="CA"/>

      </FormGroup>
      </Col>

      <Col sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleCity"> Zip Code: </Label>
      <Input type="text" name="zipcode" value=this.state.zipcode onChange=this.handleChange.bind(this) id='exampleZipCode' placeholder="95112"/>
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleState"> Phone Number: </Label>
      <Input type="text" name="phoneNumber" value=this.state.phoneNumber onChange=this.handleChange.bind(this) id='examplePhoneNumber' placeholder="408-123-4553"/>
      </FormGroup>
      </Col>
      </Row>
      <FormGroup check>
      <Label check className="term-condition">
      <Input type="checkbox"/>' '

      By creating this account, you agree to our <Button className="term-condition-button">Terms & Condintions</Button>

      </Label>
      </FormGroup>
      </Form>

      <Button color="info" onClick=this.userRegister.bind(this)>Submit</Button>' '
      this.renderRedirect()

      </Container>
      </div>
      );



      export default connect(null, register)(registerForm)





      import React, Component from 'react';
      import Button, Container, Form, FormGroup, Label, Input, Row, Col from 'reactstrap';
      import NavLink from 'reactstrap';
      import register from '../actions/auth';
      import Redirect from 'react-router-dom';
      import connect from 'react-redux';

      class registerForm extends Component
      constructor(props)
      super(props);
      this.state =
      modal: false,
      nestedModal: false,
      closeAll: false,
      email: '',
      password: '',

      redirect: false,

      confirmPassword:'',
      registerEmail: '',
      registerPassword: '',
      firstName:'',
      lastName:'',
      address:'',
      city:'',
      state:'',
      zipcode:'',
      phoneNumber:'',
      user: ,
      isLoggedIn: false
      ;



      static getDerivedStateFromProps(props, state)
      if (props.user !== state.user)
      return
      ...state,
      user: props.user
      ;

      return null;


      userRegister (e)
      e.preventDefault();
      this.props.register(
      email: this.state.registerEmail,
      password: this.state.registerPassword,
      name: this.state.firstName + ' ' + this.state.lastName,
      address:this.state.address + ' ' + this.state.city + ' ' + this.state.state + ' ' + this.state.zipcode,
      city:this.state.city,
      state:this.state.state,
      zipcode:this.state.zipcode,
      confirmPassword: this.state.confirmPassword,
      phoneNumber: this.state.phoneNumber
      );
      this.setState(
      modal: !this.state.modal,
      redirect: true
      );


      renderRedirect = () =>
      if(this.state.redirect)
      return <Redirect to ="/"/>




      handleChange = event =>
      this.setState(
      [event.target.name]: event.target.value
      );



      toggleNested()
      this.setState(
      nestedModal: !this.state.nestedModal,
      closeAll: false
      );


      toggleAll()
      this.setState(
      nestedModal: !this.state.nestedModal,
      closeAll: true
      );





      render()
      return (
      <div>
      <Container>
      <Form className = "login-body">
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegEmail">Email:</Label>
      <Input type="email" name="registerEmail" value=this.state.registerEmail onChange=this.handleChange.bind(this) id='exampleRegEmail' placeholder="name@gmail.com" />
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegPassword">Password:</Label>
      <Input type="password" name="registerPassword" value=this.state.registerPassword onChange=this.handleChange.bind(this) id='exampleRegPassword' placeholder="password" />
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleRegPassword">Confirm Password:</Label>
      <Input type="password" name="confirmPassword" value=this.state.confirmPassword onChange=this.handleChange.bind(this) id='exampleComPassword' placeholder="password" />


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col >
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleFirstName"> First Name: </Label>
      <Input type="text" name="firstName" value=this.state.firstName onChange=this.handleChange.bind(this) id='exampleFirstName' placeholder="Elizabeth" />
      </FormGroup>
      </Col>

      <Col >
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleLastName"> Last Name: </Label>
      <Input type="text" name="lastName" value=this.state.lastName onChange=this.handleChange.bind(this) id='exampleLastName' placeholder="Swann"/>


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col>

      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleAddress"> Address: </Label>
      <Input type="text" name="address" value=this.state.address onChange=this.handleChange.bind(this) id='exampleAddress' placeholder="1 Washington Square"/>


      </FormGroup>
      </Col>
      </Row>

      <Row>
      <Col xs="6" sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleCity"> City: </Label>
      <Input type="text" name="city" value=this.state.city onChange=this.handleChange.bind(this) id='exampleCity' placeholder="San Jose"/>



      </FormGroup>
      </Col>
      <Col xs="6" sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleState"> State: </Label>
      <Input type="text" name="state" value=this.state.state onChange=this.handleChange.bind(this) id='exampleState' placeholder="CA"/>

      </FormGroup>
      </Col>

      <Col sm="4">
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">

      <Label for="exampleCity"> Zip Code: </Label>
      <Input type="text" name="zipcode" value=this.state.zipcode onChange=this.handleChange.bind(this) id='exampleZipCode' placeholder="95112"/>
      </FormGroup>
      </Col>
      </Row>
      <Row>
      <Col s=12>
      <FormGroup inline className="mb-2 mr-sm-2 mb-sm-0">
      <Label for="exampleState"> Phone Number: </Label>
      <Input type="text" name="phoneNumber" value=this.state.phoneNumber onChange=this.handleChange.bind(this) id='examplePhoneNumber' placeholder="408-123-4553"/>
      </FormGroup>
      </Col>
      </Row>
      <FormGroup check>
      <Label check className="term-condition">
      <Input type="checkbox"/>' '

      By creating this account, you agree to our <Button className="term-condition-button">Terms & Condintions</Button>

      </Label>
      </FormGroup>
      </Form>

      <Button color="info" onClick=this.userRegister.bind(this)>Submit</Button>' '
      this.renderRedirect()

      </Container>
      </div>
      );



      export default connect(null, register)(registerForm)






      reactjs react-router-dom






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 23:43









      Le Tuan Anh

      43




      43



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53234668%2freactjs-oldpage-stays-at-the-bottom-after-redirecting-to-a-new-page%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53234668%2freactjs-oldpage-stays-at-the-bottom-after-redirecting-to-a-new-page%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kleinkühnau

          Makov (Slowakei)

          Deutsches Schauspielhaus