簡體   English   中英

如何在React Native的初始渲染中多次調用組件的prop方法?

[英]How to call a component's prop method several time on intial render in React Native?

我正在使用react-native-calendars的Agenda組件。 目前,我的日歷組件看起來像這樣。

const renderItem = item => <CalendarEvent item={item} />;

const Calendar = (props, context) => {
  const theme = getTheme(props, context);
  return (
    <View style={{ flex: 1 }}>
      <NetworkConnectivity />
      <Agenda
        items={R.merge(props.emptyDates, props.items)}
        renderItem={renderItem}
        renderEmptyDate={renderEmptyDate}
        rowHasChanged={rowHasChanged}
        theme={theme}
        onDayPress={props.setEmptyDate}
      />
      <ActionButton icon="event" onPress={props.openFormUserEvent} />
    </View>
  );
};

該組件首次渲染時,我希望能夠在props.items中的每個對象中調用renderItem方法或renderItem prop。 我怎么做 ?

您可以將它們放在這里,但后果自負:

<Agenda 
  ref={(ref) => {

    // this function will invoke when Agenda created in native
    // call your method here


  }}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM