Update state with refresh to rerender does not refresh!

I am having this issue using refresh in all the pages I need it, I used $updated and the state is not rerender on that page!

Any clues what is the issue?

here my refresh code:
``
<div class=“page-content ptr-content hide-navbar-on-scroll” @ptr:refresh="${refreshOrders}">

              ${userOrders.length > 0 ? $h`


export default (props, {
$,
$f7router,
$f7,
$update,
$on,
$onBeforeMount,
$onMounted,
$onBeforeUpdate,
$onUpdated,
$onBeforeUnmount,
$onUnmounted,
$store,
}) => {

    const refreshOrders = (e, done) => {

      Promise.all([
        $store.dispatch('loadOrders', {retries: 3, backoff: 300})
      ]).then((res) => {

        console.log({res}); //array data is returned ok with all orders
        $store.state.userOrders = res.orders; //I change the state content of userOrders 
        $update(); //here $update() does not rerender anything; do nothing :(
        done();


});
``

any clues?
thanks

$store.state is not reactive.
and $update know nothing about $store.

1 Like

btw:

Promise.all([]).then(a => console.log(Array.isArray(a))); // return true;

so:

any = res.orders

won’t work anyway.

1 Like

got it! thanks I think I have a clue why is not responding as it should! I am in the same page not in store.js

I made this modification and now it works!

this is working now!

userOrders = res.orders; 
$update();

this was not working as shown before:

$store.state.userOrders = res.orders; //assigned and content changes but not updated
$update();

I think in conclusion that $update will update only the state of local declared variables on the same page as declared here…

 let userOrders = $store.getters.userOrders.value;

I think I have found a solution to refresh content from other pages I will use

state.userOrders = new_array();

and then returning to that page where I want the content to be updated it will be updated already because it reads it using $store.getters.userOrders.value!

 let userOrders = $store.getters.userOrders.value;

:slight_smile:

I found the solution for the refresh deejay! thanks for the tips!
:slightly_smiling_face:

and yes the returned value after promise is done is always an array!
the issue was using $store.state.userOrders = res.orders; with update(); it does not update anything or refresh page content but using userOrders = res.orders; with update(); it refreshes the content rerendering my local vars again!

:upside_down_face: :+1:

see how it is done here => f7-core-vite - CodeSandbox
no need for $update when value is reactive.

1 Like

thanks deejay! :upside_down_face: :+1: