framework7io / framework7

Full featured HTML framework for building iOS & Android apps
http://framework7.io
MIT License
18.06k stars 3.23k forks source link

[FR] Allow React App component to take an F7 app instance #3274

Closed rafamel closed 5 years ago

rafamel commented 5 years ago

Is your feature request related to a problem? Please describe. As only one F7 instance needs to be instantiated for the application, it would make sense to have it globally available (within and outside of React Components) without resorting to dirty tricks. I have personally encountered several situations in which this would have been very helpful in terms of simplifying the development of some of my app's features.

Describe the solution you'd like Allow the App component to take either the Framework7 parameters (as it currently does) or an instance to use instead. This will allow for a greater degree of flexibility, and would be simpler to implement than #3271 while still providing most of its value.

Describe alternatives you've considered I wonder whether creating and using an additional F7 instance to have globally available would have any side effects?

nolimits4web commented 5 years ago

It can't accept instance because instance to initiliaze requires app root element in DOM. So just make it globally when you need it, in app root component, e.g.:


componentDidMount() {
  this.$f7ready((f7) => {
    window.f7 = f7
  });
}