colbymillerdev / react-native-progress-steps

A simple and fully customizable React Native component that implements a progress stepper UI.
MIT License
361 stars 145 forks source link

show dynamically the steps #61

Open hanaechahid opened 4 years ago

hanaechahid commented 4 years ago

hello, I have quizz array and i want to show the steps depending on the length and content of the array. So what I did is:

<ProgressSteps
       ref={ref => { this.progressSteps = ref }}
       activeStep={this.state.activeStep}>
       { this.state.quizz.map((quiz, i) => {
                return  (
                    <ProgressStep label={quiz.name}
                         nextBtnStyle={styles.nextBtn} nextBtnTextStyle={styles.btnText}
                         scrollViewProps={this.defaultScrollViewProps}>
                    // some other elements
                  </ProgressStep>
                )
         }
 </ProgressSteps>

but I get this error :

Unhandled JS Exception: Invariant Violation: Invariant Violation: React.cloneElement(...): The argument must be a React element, but you passed undefined.

can anyone help me?!

hanaechahid commented 4 years ago

@colbymillerdev help please !!!

r083rt commented 3 years ago

Try wrap the ProgressStep in a Fragment and add quiz.name as the key.

<ProgressSteps
       ref={ref => { this.progressSteps = ref }}
       activeStep={this.state.activeStep}>
       { this.state.quizz.map((quiz, i) => {
                return  (
                   <Fragment key={quiz.name}>
                           <ProgressStep label={quiz.name}
                              nextBtnStyle={styles.nextBtn} nextBtnTextStyle={styles.btnText}
                              scrollViewProps={this.defaultScrollViewProps}>

                            </ProgressStep>
                  </Fragment>
                )
         }
 </ProgressSteps>
minahilfaysl commented 2 years ago

@colbymillerdev hello, were you able to find a solution to this?