2

Ok so I have been trying this for a moment and I don't know how to go about it, what I want is simple, generate a brand new form but with a react transtion group effect from the old form to the new form (everytime a user clicks the submit button)

you are a lifesaver if you can provide help or a thought.

this.state.transitionTimes I tried to increment a state key maybe watch that but it doesn't work

 <div disabled={currentAccommodation.isLoading || currentRoom.isLoading} className="accommodation_popup_innerContainer_inputContainer_transition_container">
            <SwitchTransition>
              <CSSTransition
                key={this.state.isAddRoom}
                addEndListener={(node, done) =>
                  node.addEventListener('transitionend', done, false)
                }
                classNames="fade"
              >
                {(isAddRoom || this.state.isAddRoom) === true ? (
                  <CreateRoomForm
                    ScrollBar={ScrollBar}
                    LabelInput={LabelInput}
                    currentState={this.state}
                    handleChange={() => this.handleChange}
                    removeItem={this.removeItem}
                    handleMultipleChange={this.handleMultipleChange}
                    setTheState={this.setTheState}
                    error={this.state.error}
                  />
                ) : (                                       // I want the transition on this side
                  <cssTransition
                      key={this.state.transitionTimes}
                      addEndListener={(node, done) =>
                        node.addEventListener('transitionend', done, false)
                      }
                      classNames="fade">
                      <CreateAccommodationForm
                        ScrollBar={ScrollBar}
                        LabelInput={LabelInput}
                        currentState={this.state}
                        handleChange={() => this.handleChange}
                        removeItem={this.removeItem}
                        handleMultipleChange={this.handleMultipleChange}
                        setTheState={this.setTheState}
                        OnChangeDescription={this.OnChangeDescription}
                        error={this.state.error}
                  />
                  </cssTransition>

                )}
              </CSSTransition>
            </SwitchTransition>
          </div>

submit buttons

<Button
                type="submit"
                className="btn accommodation_popup_innerContainer_buttons_button"
                value={isAddRoom ? 'Add' : 'Submit'}
                onClick={
                  (isAddRoom || this.state.isAddRoom)
                    ? this.handleAddRoomBtn // for the top form
                    : this.handleSubmitBtn  // for th bottom form
                }
              />

My submit button

 handleAddRoomBtn = async (e) => {
    e.preventDefault();

    await this.setState({
      ...this.initiaState,
      transitionTimes: this.state.transitionTimes + 1
    })
    console.log(this.state)

  };
bihire boris
  • 1,530
  • 3
  • 19
  • 44
  • 1
    post the entire code in the file, there's some stuff that is missing to understand what's going on here – Roy.B May 03 '20 at 10:45
  • I just posted as much related to the code, The file is too big it might be hard to read @Roy.B – bihire boris May 03 '20 at 10:56
  • what I want is simple, generate a brand new form but with a react transtion group effect from the old form to the new form (everytime a user clicks the submit button) @Roy.B – bihire boris May 03 '20 at 11:05

0 Answers0