omcljs / om

ClojureScript interface to Facebook's React
6.65k stars 364 forks source link

set-query! fails when the component's query has been nested deeper than the top level in the parent's query #874

Open symfrog opened 7 years ago

symfrog commented 7 years ago

Using set-query! in a component when the component's query has been nested deeper than the top level in the parent's query results in the following error:

Uncaught TypeError: Cannot read property 'call' of null
    at clojure$zip$node (zip.cljs?rel=1496865979076:62)
    at om$next$cascade_query (next.cljc?rel=1496865999367:1677)
    at om$next$build_index_STAR_ (next.cljc?rel=1496865999367:1761)
    at om$next$build_index_STAR_ (next.cljc?rel=1496865999367:1766)
    at om$next$build_index_STAR_ (next.cljc?rel=1496865999367:1766)
    at om.next.Indexer.om$next$protocols$IIndexer$index_root$arity$2 (next.cljc?rel=1496865999367:1802)
    at om$next$protocols$index_root (protocols.cljc?rel=1496865983284:5)
    at om.next.Reconciler.om$next$protocols$IReconciler$reindex_BANG_$arity$1 (next.cljc?rel=1496865999367:2457)
    at om$next$protocols$reindex_BANG_ (protocols.cljc?rel=1496865983284:19)
    at Function.om.next.set_query_BANG_.cljs$core$IFn$_invoke$arity$3 (next.cljc?rel=1496865999367:1320)

I have created a minimal case using 1.0.0-beta1.

Everything (mutations, path metadata, component refresh etc.) works correctly in the subcomponent, except for dynamic queries and the use of set-query! in the subcomponent. If the call to update-query! on line 23 (https://gist.github.com/symfrog/75bf8955722b26cd4370989dace60e2e#file-placeholders-cljs-L23) is removed, then the issue does not occur.

A recording is available, note the error in the console.

stevebuik commented 6 years ago

I just hit this as well using set-query!