Created
December 14, 2016 20:45
-
-
Save gardnervickers/687da840630c07d1e4f9721201a051c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns cards.query-key-appstate-bug | |
(:require [untangled.client.cards :as uccards :include-macros true] | |
[devcards.core :as dc :refer-macros [defcard]] | |
[untangled.client.core :as uc :refer [initial-state InitialAppState]] | |
[om.next :as om :refer [defui]] | |
[om.dom :as dom] | |
[untangled.client.mutations :as m] | |
[clojure.string :as string] | |
[untangled.client.logging :as log])) | |
(defui ^:once ActiveUsersTab | |
static InitialAppState | |
(initial-state [clz params] {:which-tab :active-users}) | |
static om/IQuery | |
(query [this] [:which-tab]) | |
static om/Ident | |
(ident [this props] | |
[(:which-tab props) :tab]) | |
Object | |
(render [this])) | |
(def ui-active-users-tab (om/factory ActiveUsersTab)) | |
(defui ^:once HighScoreTab | |
static InitialAppState | |
(initial-state [clz params] {:which-tab :high-score}) | |
static om/IQuery | |
(query [this] [:which-tab]) | |
static om/Ident | |
(ident [this props] | |
[(:which-tab props) :tab]) | |
Object | |
(render [this])) | |
(def ui-high-score-tab (om/factory HighScoreTab)) | |
(defui ^:once Union | |
static InitialAppState | |
(initial-state | |
[clz params] | |
(initial-state HighScoreTab nil)) | |
static om/IQuery | |
(query [this] | |
{:active-users (om/get-query ActiveUsersTab) | |
:high-score (om/get-query HighScoreTab)}) | |
static om/Ident | |
(ident [this props] [(:which-tab props) :tab])) | |
(def ui-settings-viewer (om/factory Union)) | |
(defui ^:once Root | |
static InitialAppState | |
(initial-state [clz params] {:ui/react-key "A" | |
:current-tab (initial-state Union nil)}) | |
static om/IQuery | |
(query [this] [{:current-tab (om/get-query Union)} | |
:ui/react-key]) | |
Object | |
(render [this] | |
(let [{:keys [ui/react-key] :as props} (om/props this)] | |
(dom/div #js {:key (or react-key)} (str react-key))))) | |
(defcard QueryKeyAppstateBug | |
"" | |
(uccards/untangled-app Root) | |
{} | |
{:inspect-data true}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment