Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for getFragment from a dynamic component in Relay

Current License: CC BY-SA 3.0

21 events
when toggle format what by license comment
Mar 7, 2016 at 12:58 comment added Ramsay Lanier Will do. In the meantime my solution has to remove the condition from the map function and pass a boolean to the child component, then adding a condition to each child component query. It works but I end up with empty fragments.
Mar 7, 2016 at 10:20 comment added steveluscher I'm stumped! I drummed up a Relay Playground that tries to get as close to your implementation as possible. Can you take a look at this, and see if you can get it into a state where it repros the problem? tinyurl.com/zvq3a3z
Mar 7, 2016 at 2:56 comment added Ramsay Lanier Sorry, one last thing - if I remove the map and try to us PostList by itself with the condition - it still doesn't work unless I initially set showPosts to true.
Mar 5, 2016 at 17:43 comment added Ramsay Lanier Also, if I console.log(this.props.viewer) from Page render, I don't even see a RelayFragmentPointer. If, for example, I set showPosts to true in initial variables, everything runs fine and I see the RelayFragmentPointer.
Mar 5, 2016 at 0:31 comment added Ramsay Lanier I'm still getting the same error that PostList is expecting viewer to be Relay data. Same error as before.
Mar 5, 2016 at 0:20 comment added steveluscher The mapping shouldn't need to re-run, since now you've primed the if(...) calls with the right variable for each fragment. When the variables change, the if(...) should be reevaluated with the new variable value. Despite the map(...) not re-running, what behavior are you seeing or not seeing now?
Mar 3, 2016 at 14:30 comment added Ramsay Lanier Still nope. The mapping only runs before the component mounts. When the variables update the map doesnt rerun. Verrified that the variables are getting update properly though - I feel like this is sooooo close.
Mar 3, 2016 at 5:34 history edited steveluscher CC BY-SA 3.0
Added a note that route conditional functions may only return a single fragment reference
Mar 3, 2016 at 5:09 comment added steveluscher Thank you for doing that. I was able to spot the problem right away. I'll update the answer in a bit, but in the meantime take a look at this fix. Basically you have to move all of your variable wrangling into prepareVariables(); a Relay variable is not a boolean, so you can't do things like if(variables.foo) { ... } in your interpolation. gist.github.com/steveluscher/3681d7795fbd2f13141b
Mar 2, 2016 at 4:16 comment added Ramsay Lanier Here is page Here is PostList
Feb 26, 2016 at 7:00 comment added steveluscher Strange. Are you able to share more of the code, particularly the implementations of PostList and WordpressPage?
Feb 23, 2016 at 14:16 comment added Ramsay Lanier No dice - it just doesn't render anything and I still get the "expected prop viewer" error
Feb 23, 2016 at 9:02 comment added steveluscher What happens if you check to see if viewer is null before rendering PostList? render() { return this.props.viewer == null ? null : <PostList viewer={this.props.viewer} />; }
Feb 21, 2016 at 23:47 comment added Ramsay Lanier I'm still getting a "Expected prop viewer supplied to PostList to be data fetched by Relay." The query runs, gets the layout, then reruns, but before it reruns I think PostList gets rendered. I need to only render PostList after it's gotten the fragment from PostList. Thoughts?
Feb 21, 2016 at 8:56 comment added steveluscher I don't think so, because condition here represents a ‘variable’ data type, and not actually a raw boolean. This lets Relay evaluate the variable over time to see if the if() condition passes or fails.
Feb 19, 2016 at 15:43 comment added Ramsay Lanier Will the condition only work for boolean variables? I couldn't set a 'Layout' variable and check that it equals a string?
Feb 19, 2016 at 1:53 comment added steveluscher I released v0.7.1 a moment ago, just for you. :)
Feb 18, 2016 at 4:03 vote accept Ramsay Lanier
Feb 18, 2016 at 4:03 comment added Ramsay Lanier Thanks! Any idea when 0.7.1 will be released?
Feb 18, 2016 at 1:57 history edited steveluscher CC BY-SA 3.0
deleted 4 characters in body
Feb 18, 2016 at 1:16 history answered steveluscher CC BY-SA 3.0
toggle format

AltStyle によって変換されたページ (->オリジナル) /