React Native Modal
Modal はページが変わるなり、アプリが background に行くなりしてから戻ってくると、state は表示することになっていても目視はできず、動作もなにかおかしくなる
このようになる仕組みは理解していない
Appstate の変更時に modal を閉じるように state を変えるというのがイディオムらしい
Modal not opens after sleep mode or inactivity in the app in react-native - Stack Overflow
Modal · React Native
AppState · React Native
そもそも React Native での state の扱いはどうなっているのか?
ページ変わっても unmount されるわけではない、という記述をどこかで読んだ気がする
ここに書いてあった
Navigation lifecycle | React Navigation
React Fundamentals · React Native
React Navigation の useFocusEffect
useFocusEffect | React Navigation
「Focus されたとき」だけはなくて、「Focus されているとき」
なので結構毎回走る
useContext? だっけ?を中で使えと言うことらしい
The cleanup function runs when the previous effect needs to be cleaned up, i.e. when dependencies change and a new effect is scheduled and when the screen unmounts or blurs.
これは appstate が変わった時には動かない