React Component Extensions
If you use functional components, then previously described extensions will not work. Framework7 instance, f7ready
method and can be imported directly from Framework7-React library. Device, Request and Support can be imported directly from Framework7 core library.
import { Device, Request, Support } from 'framework7';
Framework7-React components are build with Phenome.js, so they are empowered with some extra features like Slots and Events.
All Framework7-React components use slots
to distribute children across component structure. They work exactly the same as and Vue.js Slots.
export default () => (
<Page>
<p slot="fixed">I'm fixed page element</p>
<p>I'm in scrollable page area</p>
<List>
<ListItem>
<img slot="media" src="path/to/image.png" />
<span slot="title">Title 1</span>
<span slot="title">Title 2</span>
</ListItem>
</List>
</Page>
)
Renders to:
All Framework7-React components support events, which are actually props, and their listeners must be assigned as prop.
For example <Page>
component supports pageInit
, pageBeforeIn
and other , so to handle such events:
render() {
return (
<Page onPageBeforeIn={this.onPageBeforeIn.bind(this)} onPageInit={this.onPageInit.bind(this)}>
...
</Page>
)
}
onPageBeforeIn() {
// do something on page before in
}
onPageInit() {
// do something on page init