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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@
(if (and config/cached-webviews-enabled? platform/android? dapp?) (if (and config/cached-webviews-enabled? platform/android? dapp?)
(reagent.core/create-class (reagent.core/create-class
(let [dapp-name-sent? (reagent.core/atom false)] (let [dapp-name-sent? (reagent.core/atom false)]
{:component-will-mount {:component-did-mount
(fn [] (fn []
;; unfortunately it's impossible to pass some initial params ;; unfortunately it's impossible to pass some initial params
;; to view, that's why we have to pass dapp-name to the module ;; 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] installed-packs [:stickers/installed-packs-vals]
bottom-anim-value (anim/create-value (styles/stickers-panel-height)) bottom-anim-value (anim/create-value (styles/stickers-panel-height))
alpha-value (anim/create-value 0)] 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 [react/animated-view {:style {:background-color :white
:height (styles/stickers-panel-height) :height (styles/stickers-panel-height)
:transform [{:translateY bottom-anim-value}] :transform [{:translateY bottom-anim-value}]

View File

@ -375,10 +375,9 @@
(letsubs [progress-bar (atom nil) (letsubs [progress-bar (atom nil)
listener (atom nil) listener (atom nil)
card-state [:hardwallet-card-state]] card-state [:hardwallet-card-state]]
{:component-will-mount (fn [] {:component-did-mount (fn []
(when @listener (when @listener
(.removeListener @listener))) (.removeListener @listener))
:component-did-mount (fn []
(reset! listener (reset! listener
(.addListener (event-emitter) (.addListener (event-emitter)
"keycardInstallationProgress" "keycardInstallationProgress"

View File

@ -103,11 +103,6 @@
two-pane? (reagent/atom (dimensions/fit-two-pane?))] two-pane? (reagent/atom (dimensions/fit-two-pane?))]
(reagent/create-class (reagent/create-class
{:component-did-mount {: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 [] (fn []
(.addEventListener (react/dimensions) (.addEventListener (react/dimensions)
"change" "change"
@ -121,7 +116,10 @@
(when-not @initial-view-id (when-not @initial-view-id
(reset! initial-view-id @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 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 :component-will-unmount
utils.universal-links/finalize utils.universal-links/finalize
:component-will-update :component-will-update

View File

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