将数组和显示数据从 API 传递到事件日历

Passing array and display data from API to event calendar

我正在使用 https://github.com/joshjhargreaves/react-native-event-calendar 在 React Native 中制作一个简单的 dayview 日历并从 API 获取数据。我正在使用 axios 获取数据

 const[title,setTitle]=useState('')
    const[start,setStart]=useState('')
    const[end,setEnd]=useState('')
    const[summary,setSummary]=useState('')

  const data={
    title,
    start,
    end,
    summary
  }
  
  const[timetable,setTimetable]=useState([]);

  useEffect(() => {
      getData()
  },[])

  const getData=()=>{
      Axios.get('http://sh3ll.my.id/events/timetable.json')
      .then(res=>{
          console.log('res getData:', res.data)
          setTimetable(res.data)
      })
  }

如何在事件 属性 上传递数组,我无法显示来自 api

的数据
      <EventCalendar
          events={??}
          width={width}
          size={60}
          initDate={'2020-11-17'}
          scrollToFirst
        /> 

试试这个

const[events,setEvents]=useState([]); // default empty

const getData=()=>{
      Axios.get('http://sh3ll.my.id/events/timetable.json')
      .then(res=>{
          console.log('res getData:', res.data)
          setEvents(res.data.timetable) // set here
      })
  }



<EventCalendar
          events={events} // use here
          width={width}
          size={60}
          initDate={'2020-11-17'}
          scrollToFirst
        />