繁体   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