Move from componentWillMount to componentDidMount

Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
Pedro Pombeiro 2019-08-22 10:22:20 +02:00
parent ffcba77486
commit a5907fe0ca
No known key found for this signature in database
GPG Key ID: C4A24185B2AA48A1
10 changed files with 29 additions and 38 deletions

View File

@ -26,8 +26,8 @@
(defn app-root [props]
(let [keyboard-height (subscribe [:keyboard-height])]
(reagent/create-class
{:component-will-mount
(fn []
{:component-did-mount
(fn [this]
(.addListener (react/keyboard)
"keyboardDidShow"
(fn [e]
@ -48,9 +48,7 @@
(.addEventListener rn-dependencies/react-native-languages "change" on-languages-change)
(.addEventListener (rn-dependencies/react-native-shake)
"ShakeEvent"
on-shake))
:component-did-mount
(fn [this]
on-shake)
(dispatch [:set-initial-props (reagent/props this)]))
:component-will-unmount
(fn []

View File

@ -22,11 +22,9 @@
(defn app-root [props]
(if config/mobile-ui-for-desktop?
(reagent/create-class
{:component-will-mount
(fn []
(.addEventListener (react/app-state) "change" app-state-change-handler))
:component-did-mount
{:component-did-mount
(fn [this]
(.addEventListener (react/app-state) "change" app-state-change-handler)
(re-frame/dispatch [:set-initial-props (reagent/props this)]))
:component-will-unmount
(fn []

View File

@ -25,8 +25,8 @@
(defn app-root [props]
(let [keyboard-height (subscribe [:keyboard-height])]
(reagent/create-class
{:component-will-mount
(fn []
{:component-did-mount
(fn [this]
(.addListener (react/keyboard)
"keyboardWillShow"
(fn [e]
@ -44,9 +44,7 @@
(.addEventListener rn-dependencies/react-native-languages "change" on-languages-change)
(.addEventListener (rn-dependencies/react-native-shake)
"ShakeEvent"
on-shake))
:component-did-mount
(fn [this]
on-shake)
(dispatch [:set-initial-props (reagent/props this)]))
:component-will-unmount
(fn []

View File

@ -151,7 +151,7 @@
(let [keyboard-shown? (reagent/atom false)
listeners (atom [])]
(reagent/create-class
{:component-will-mount
{:component-did-mount
(fn []
(when platform/android?
(reset!

View File

@ -145,7 +145,7 @@
(letsubs [status-properties [:connectivity/status-properties]
view-id [:view-id]
window-width (reagent/atom 0)]
{:component-will-mount
{:component-did-mount
(fn []
(when anim-translate-y
(if (:connected? status-properties)

View File

@ -16,7 +16,7 @@
(if (and config/cached-webviews-enabled? platform/android? dapp?)
(reagent.core/create-class
(let [dapp-name-sent? (reagent.core/atom false)]
{:component-will-mount
{:component-did-mount
(fn []
;; unfortunately it's impossible to pass some initial params
;; to view, that's why we have to pass dapp-name to the module

View File

@ -129,7 +129,7 @@
installed-packs [:stickers/installed-packs-vals]
bottom-anim-value (anim/create-value (styles/stickers-panel-height))
alpha-value (anim/create-value 0)]
{:component-will-mount #(show-panel-anim bottom-anim-value alpha-value)}
{:component-did-mount #(show-panel-anim bottom-anim-value alpha-value)}
[react/animated-view {:style {:background-color :white
:height (styles/stickers-panel-height)
:transform [{:translateY bottom-anim-value}]

View File

@ -375,16 +375,15 @@
(letsubs [progress-bar (atom nil)
listener (atom nil)
card-state [:hardwallet-card-state]]
{:component-will-mount (fn []
(when @listener
(.removeListener @listener)))
:component-did-mount (fn []
(reset! listener
(.addListener (event-emitter)
"keycardInstallationProgress"
(fn [params]
(when @progress-bar
(.setNativeProps @progress-bar params))))))}
{:component-did-mount (fn []
(when @listener
(.removeListener @listener))
(reset! listener
(.addListener (event-emitter)
"keycardInstallationProgress"
(fn [params]
(when @progress-bar
(.setNativeProps @progress-bar params))))))}
[react/view styles/loading-view-container
[react/view styles/center-container
[react/text {:style styles/center-title-text}

View File

@ -103,11 +103,6 @@
two-pane? (reagent/atom (dimensions/fit-two-pane?))]
(reagent/create-class
{:component-did-mount
(fn []
(re-frame/dispatch [:set-two-pane-ui-enabled @two-pane?])
(log/debug :main-component-did-mount @view-id)
(utils.universal-links/initialize))
:component-will-mount
(fn []
(.addEventListener (react/dimensions)
"change"
@ -121,7 +116,10 @@
(when-not @initial-view-id
(reset! initial-view-id @view-id))
(reset-component-on-mount view-id main-component false)
(reset-component-on-mount view-id main-component-two-pane true))
(reset-component-on-mount view-id main-component-two-pane true)
(re-frame/dispatch [:set-two-pane-ui-enabled @two-pane?])
(log/debug :main-component-did-mount @view-id)
(utils.universal-links/initialize))
:component-will-unmount
utils.universal-links/finalize
:component-will-update

View File

@ -69,10 +69,10 @@
(let [amount-input (atom nil)
handler #(when (and scroll @scroll @amount-input (.isFocused @amount-input)) (.scrollToEnd @scroll))]
(reagent/create-class
{:component-will-mount (fn [_]
;;NOTE(goranjovic): keyboardDidShow is for android and keyboardWillShow for ios
(.addListener (react/keyboard) "keyboardDidShow" handler)
(.addListener (react/keyboard) "keyboardWillShow" handler))
{:component-did-mount (fn [_]
;;NOTE(goranjovic): keyboardDidShow is for android and keyboardWillShow for ios
(.addListener (react/keyboard) "keyboardDidShow" handler)
(.addListener (react/keyboard) "keyboardWillShow" handler))
:reagent-render (fn [opts] (render-send-transaction-view
(assoc opts :amount-input amount-input)))})))