setState call error

Hello
I’m in main
var app = new Framework7({...});
i’ve created a function under root methods… what is the correct way to call setState?
this. and app. produce an error

app.$setState({
          firstname: user_info.firstname,
          lastname: user_info.lastname,
        }, () => {
          // DOM updated
        });

thanks in advance

In router component: https://framework7.io/docs/router-component.html

Thanks for reply
probably i’m stupid… I don’t know

if I call self.$setState() into page component works fine
but If I call into a root method, setState give me error

loginUser: function(e, p){

      app.request.post(app.data.apiurl, 
      { resource: 'Login', email: e, password: p }, 
      function (data, status, xhr) {
        console.log(data.content.response);
        var resp = data.content.response;

        if(resp.status == "success"){
          var user_info = resp.data.customer_info;
        
          /*Here I would call setState to update root data */
          
        }else{
          app.preloader.hide();
          app.dialog.alert('Login non riuscito');
        }
        
      }, function (status, xhr) {
        console.log(xhr);
      }, 'json');
  
    },

This is normal behavior

so… how can update root data (and DOM) from a root method? Is this operation not permitted?

Access root data from component: this.$app.data.varName = 'new value';
DOM: $ - Dom7: https://framework7.io/docs/dom7.html

I do like this to setState from root methods.

in any_page.jsx

componentDidMount() {
    const self = this;
    this.$f7.methods.updateUser(self);
    //
    this.$f7ready((f7) => {
      // Call F7 APIs here
    });
}

in app.jsx root methods

methods: {
	updateUser:function(rootSelf){
		const self = this;
		rootSelf.setState({
	         isSignedIn: false,
	         userProfile: false,
        });
	},
}

Correct me if I’m doing any bad practice!
Happy Coding!