Fork me on GitHub

So I would really like a framework focused on serverside-rendering and adding real-time updates to elements once the page has loaded and the javascript has been engaged. React seems to be the most sensible way towards this (keep track of react keys while dishing pages out from the server and update elements once the js loads clientside). Are there any examples of this workflow floating around?


Hi-- beginner question with I have a sample/toy app using on the front end with transact, query, etc. working running through the reconciler. I'm now wondering how I can replicate the react behavior of local state in a component via this.setState ({...})-- e.g. a transact! seems both unnecessary and undesirable as no other component will need to track this state. When I try (om/set-state! this {:startDate "01/01/2018"}), i get a "No queries exist for component path ..." with my core/reconciler comp and the component i'm trying to set state on, and its not clear to me what i'm doing wrong. Anyone around and willing to help me understand how to do this?


the shorter form of this question might be: must i query down the component chain for any component on which i want to set state? (this seems to be more propslike than state a.f.a.i. am familiar with react, hence why i am naively thinking this isn't the case)


I'm trying to install 1.0.0-beta2-SNAPSHOT to get React 16 support, but I can't find it. Are snapshot builds not actually published?


so it seems like adding:

(initLocalState [this]
                  {:startDate (f/unparse (f/formatters :date) (cljs-time.core/now))
                   :endDate (f/unparse (f/formatters :date) (cljs-time.core/plus (cljs-time.core/now) (cljs-time.core/days 7)))})
lets me get state without the queries error, and i can set-state! in an :onChange and it works, but for each onChange event fire, I see the "No queries exist..." error


I've not been able to find any documentation around this sort of state input manipulation... any help on the "" approach to this would be great (from the todo-mvc examples, it seems pretty clear a simple transact! and props pass through would work, but I'm looking to take more of a react component setState approach here than a props based central data store)


@mrkiouak om/set-state! first sets the state locally (if your component implements ILocalState) and then schedules a render via the reconciler (assuming you have one). The No queries exist error is coming from the latter, and probably means you've done something that isn't allowed with your queries.


If you're only interested in setting the state locally, you can use om/react-set-state! which literally calls setState on the component, but doesn't involve the reconciler.


I've used this for performance-critical things where I don't want to schedule renders via the reconciler, but I think om/set-state! is the preferred way, and will work fine once you've figured out what's causing the query error.


@jthomson -- thanks for explaining both effects of the om/set-state!, I couldn't tell whether or not this was a direct effect of the state call or not. Is there a good reference for ILocalState other than the source code? I'm having trouble finding things like this protocol I would know I want to/need to use if I knew about it, but simply am not aware and not sure if a reference exists where i might find something like this.


@jthomson I dont see the error at any point except when set state is called-- e.g., if i understand your above, i should see the error thrown any time offending component is rendered, but the query exception only appears on set state call, not on a page refresh. Did I misunderstand the issue, or does this suggest your above intuition isn't the case?