Fork me on GitHub
#om
<
2016-06-08
>
jasonjckn00:06:51

no luck with that

hlolli08:06:22

I've had this error Uncaught Invariant Violation: Objects are not valid as a React child before, but then I was inserting react motion element nested in render (under sablono html tag). So maybe you have some react element wrongly nested? But this is vague description, long time ago since I had this.

mitchelkuijpers10:06:56

@jasonjckn: When react starts throwing invariant violations you’re better of just refreshing the page in my experience.

dnolen14:06:10

looks like an interesting read - probably worth ruminating on

peeja16:06:25

@noonian: Oh, sweet! Good find, thanks!

peeja20:06:57

Puzzler: I've got a component which shows a list and details of the item selected from the list. Clicking an item selects the item. My plan is to store the id of the selected item as a query param; when an item is clicked, I'll set-query! to set the new selected item. But now, a hitch: I'd like to select the first item in the list by default. I don't know what the id of that item will be upfront, so I can't query for it with an ident. If I want to query for the first item in a list, do I have to use a parameterized property, and implement that in my parser?

peeja20:06:16

Something like [(:the/list {:index 0})]?

noonian20:06:43

If you didn’t want to use dynamic query params, you could store the selected items ident in your app-state and query for that with a custom read impl for that key that returns the first in the list if there is no item selected. If this is not a top-level query though you would probably need your parser to be recursive to get the read impl called.

noonian20:06:06

Or if you don’t mind overquerying for the detail data for everything in the list can just render the first item of the list in your render fn if you don’t get props for the selected item.

noonian20:06:23

And then query for the selected item with a link

peeja20:06:09

Yeah, that might work.

peeja20:06:39

If not, though, is query params a reasonable solution? is this the sort of problem they solve normally?

noonian21:06:25

I haven’t used them at all really. But I imagine they are most useful when they are used for state that is only relevant to the component like open/closed for an accordion thing. I think the id of a selected component doesn’t work as well because the value of the param is dependent on the shape of the app state (the first item in the list). I think its an anti pattern in react to update local state based on props, and I consider dynamic query params to be a kind of local state.

peeja21:06:59

Er, I actually meant to say are parameterized properties a reasonable solution. 😛

peeja21:06:18

But yeah, I agree with what you just said. Storing the id of the item the user has clicked in a query param would be appropriate; noticing the first element in the list coming in on the params and setting the query param based on that would be weird.