chrisfisher / react-native-directed-scrollview

UNMAINTAINED- see below. A natively implemented scrollview component which lets you specify different scroll directions for child content.
MIT License
149 stars 67 forks source link

The specified child already has a parent #3

Closed coderdave closed 7 years ago

coderdave commented 7 years ago

Sometimes I get this error: "The specified child already has a parent. You must call removeView() on the child's parent first."

I don't remember getting this error before using this library. Is it related to this library?

android_emulator_-_nexus_5x_api_25_x86_5554

chrisfisher commented 7 years ago

@coderdave I haven't seen that one before. Can you provide some example code of how you are using the scrollview?

coderdave commented 7 years ago

Thanks for getting back with me so quickly. The code isn't complicated, here's the gist of it.

      <ScrollView style={styles.dayContentView}
        bounces={true}
        contentContainerStyle={{width: this.state.store.contentContainerWidth, height: this.state.store.contentContainerHeight}}
        directionalLockEnabled={true}
        showsHorizontalScrollIndicator={false}
        showsVerticalScrollIndicator={true}
      >
        <ScrollViewChild scrollDirection={'both'}>
          <For each="timeSlot" of={this.state.store.timeSlots} index="timeSlotIndex">

            <View key={timeSlot} style={{flexDirection: 'row'}}>

              <View style={[styles.timeTextView, {borderBottomWidth: timeSlot === this.state.store.timeSlotEnd ? 1 : null}]}>
                ...
              </View>

              <View style={[styles.emptyApptSlotWrapper, {borderBottomWidth: timeSlot === this.state.store.timeSlotEnd ? 1 : null}]}>
                ...
              </View>

            </View>

            <For each="appointment" of={this.state.store.appointments}>

              <If condition={appointment[`start${timeSlot}`]}>

                <TouchableHighlight
                  style={[styles.apptStartBox, {top: timeSlotIndex * 32, height: appointment.height, left: appointment.left}, styles[`${appointment.status}`]]}
                  onPress={_ => this.openAppointmentView(appointment.id)} underlayColor={this.getApptUnderlayColor(appointment)}
                  key={appointment.id}>
                  <View>
                    ...
                  </View>
                </TouchableHighlight>
              </If>

            </For>

          </For>
        </ScrollViewChild>

      </ScrollView>
chrisfisher commented 7 years ago

@coderdave I can't repro this one I'm afraid. Are you still getting the error?

coderdave commented 7 years ago

I haven't received that error in a while, maybe it was something else.