Fork me on GitHub

no luck with that


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.


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


looks like an interesting read - probably worth ruminating on


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


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?


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


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.


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.


And then query for the selected item with a link


Yeah, that might work.


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


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.


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


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.