entria / ReactNavigationRelayModern

React Navigation integration with Relay
173 stars 23 forks source link

How does one prepare data for SectionList? #23

Closed ssomnoremac closed 6 years ago

ssomnoremac commented 6 years ago

I can't resolve how to use RelayModern for RN SectionList. In other words, where do I prepare data like this

  [{name: "Event1", day: "Tuesday"},
  {name: "Event2", day: "Tuesday"},
  {name: "Event3", day: "Wednesday"}, ...]

to look like this:

[{data: [...], key: "Tuesday"},
 {data: [...], key: "Wednesday"},...]

Surely not in the render function. That doesn't seem performant. Isn't this what prepareVariables used to allow for? Where is that functionality in RelayModern?

sibelius commented 6 years ago

On render is good enough

Or u could try to improve this doing a setState on componentWillReceiveProps

sibelius commented 6 years ago

prepareVariables was for input, on Modern you should be explicit for this computed prepared variables

ssomnoremac commented 6 years ago

Oh yeah, it was for input, I remember now. Yeah, I will try it for a while in render and see how performance is. It just didn't seem ideal to load more on scroll and have it re-sort every time but perhaps it really isn't an issue.

ssomnoremac commented 6 years ago

@sibelius thanks for getting back about it!