What approaches there are to find out why https://callstack.github.io/react-native-paper/text-input.html this is "flickering" when I do the basic adapt-react-class to it and use re-frame subscription as the value and dispatch the value on-change-text? I've been able to get it to work properly if I use a functional component (reagent 1.1.0 feature) and use local hook state instead of re-frame. So – basically it seems to mount a new component every time instead of reusing the current when the value changes?e
@mikko Re the pointers to default-value above, see a full explanation here: https://increasinglyfunctional.com/2019/03/28/why-clojurescript-react-native-text-input-slow.html
Thanks all 🙂 I opted for the dispatch-sync & flush option since the component I'm using does not seem to have a default-value property (at least according to the docs) – and maybe I can provide my own textfield to the game but for now I'll stick to the first option
So just doing
[:> TextInput
{:label (t/translate :company-mobile.login/username)
:value @username
:onChangeText (fn [t] (re/dispatch [::login/set-username t]))}]
causes the flickeryeah basically. I know i had a solution for that let me check
try to remove the :value if i am not mistaken it should prevent constant re-rendering
Yeah, that might work but if we want to get the initial value through the subscription that does not work. It has the render prop that can be used to give it a textfield to use – I'll try to use that.
I think the issue is the same as with web side when using material-ui we need to provide our own input field to it in order for it not to flicker
OK. I think I solved it 🙂 I just use
(fn [t]
(re/dispatch-sync (conj dispatch t))
(r/flush))
And the flickering stopsremoving :value didn't help? great 👍 thanks for sharing solution
@lepistane sure, removing :value works but if we want the field to be managed and use the value from the state it can't be removed. If eg. we have an initial value we want there then it's a hassle to get in
Thanks for your help as well!
Try with :default-value
Use defaultValue