mirror of
https://github.com/flarum/framework.git
synced 2025-01-21 13:44:58 +08:00
common: rework Component#render again to simplify substite m(class, props)
Can be used instead of m(DiscussionList, app.cache.discussionList.props), for example - it's now app.cache.discussionList.render()
This commit is contained in:
parent
5bc6e52190
commit
66b839d241
|
@ -65,18 +65,7 @@ export default class Component<T extends ComponentProps = any> implements ClassC
|
|||
}
|
||||
|
||||
render() {
|
||||
return m.fragment(
|
||||
{
|
||||
...this.props,
|
||||
oninit: (...args) => this.oninit(...args),
|
||||
oncreate: (...args) => this.oncreate(...args),
|
||||
onbeforeupdate: (...args) => this.onbeforeupdate(...args),
|
||||
onupdate: (...args) => this.onupdate.bind(...args),
|
||||
onbeforeremove: (...args) => this.onbeforeremove.bind(...args),
|
||||
onremove: (...args) => this.onremove.bind(...args),
|
||||
},
|
||||
this.view()
|
||||
);
|
||||
return m(this.constructor, this.props);
|
||||
}
|
||||
|
||||
static component(props: ComponentProps | any = {}, children?: Mithril.Children) {
|
||||
|
|
|
@ -20,7 +20,7 @@ export default class CommentPost extends Post {
|
|||
*/
|
||||
revealContent: boolean = false;
|
||||
|
||||
postUser: Vnode<{}, PostUser>;
|
||||
postUser!: Vnode<{}, PostUser>;
|
||||
|
||||
oninit(vnode) {
|
||||
super.oninit(vnode);
|
||||
|
|
|
@ -76,7 +76,7 @@ export default class IndexPage extends Page {
|
|||
view() {
|
||||
if (!app.cache.discussionList) return;
|
||||
|
||||
const discussionList = m(DiscussionList, app.cache.discussionList.props);
|
||||
const discussionList = app.cache.discussionList.render();
|
||||
|
||||
return (
|
||||
<div className="IndexPage">
|
||||
|
|
|
@ -15,7 +15,7 @@ export type NotificationItem = {
|
|||
name: string;
|
||||
|
||||
/**
|
||||
* The icon to display in the column header/notificatio grid row.
|
||||
* The icon to display in the column header/notification grid row.
|
||||
*/
|
||||
icon: string;
|
||||
|
||||
|
@ -60,6 +60,7 @@ export default class NotificationGrid extends Component<NotificationGridProps> {
|
|||
state: !!preference,
|
||||
disabled: typeof preference === 'undefined',
|
||||
onchange: () => this.toggle([key]),
|
||||
oninit: vnode => (this.inputs[key] = vnode.state),
|
||||
});
|
||||
})
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user