-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: createComponent should return ele in fn
- Loading branch information
Showing
9 changed files
with
188 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,38 @@ | ||
import { GetState, useRef, render } from "extreme"; | ||
import { GetState, useRef, createComponent } from "extreme"; | ||
import template from "./index.html?raw"; | ||
|
||
export const CustomComponent = ( | ||
element: HTMLElement, | ||
props: { | ||
open?: boolean | GetState<boolean>; | ||
} = {} | ||
) => { | ||
const defaultData = [ | ||
{ | ||
src: "https://img.alicdn.com/imgextra/i4/O1CN01QYQ1QI1CZQYQ1QYQI_!!6000000001382-2-tps-200-200.png", | ||
content: "这是一段描述1,但是我是新的默认数据", | ||
title: "这是一段标题1", | ||
key: 1, | ||
}, | ||
{ | ||
src: "https://img.alicdn.com/imgextra/i4/O1CN01QYQ1QI1CZQYQ1QYQI_!!6000000001382-2-tps-200-200.png", | ||
content: "这是一段描述2", | ||
title: "这是一段标题2", | ||
key: 2, | ||
}, | ||
]; | ||
const divRef = useRef(); | ||
export const CustomComponent = createComponent( | ||
"CustomComponent", | ||
( | ||
props: { | ||
open?: boolean | GetState<boolean>; | ||
} = {} | ||
) => { | ||
const defaultData = [ | ||
{ | ||
src: "https://img.alicdn.com/imgextra/i4/O1CN01QYQ1QI1CZQYQ1QYQI_!!6000000001382-2-tps-200-200.png", | ||
content: "这是一段描述1,但是我是新的默认数据", | ||
title: "这是一段标题1", | ||
key: 1, | ||
}, | ||
{ | ||
src: "https://img.alicdn.com/imgextra/i4/O1CN01QYQ1QI1CZQYQ1QYQI_!!6000000001382-2-tps-200-200.png", | ||
content: "这是一段描述2", | ||
title: "这是一段标题2", | ||
key: 2, | ||
}, | ||
]; | ||
const divRef = useRef(); | ||
|
||
return render(element, template, { | ||
state: { | ||
defaultData, | ||
open: props.open, | ||
}, | ||
ref: { | ||
divRef, | ||
}, | ||
}); | ||
}; | ||
return { | ||
template, | ||
state: { | ||
defaultData, | ||
open: props.open, | ||
}, | ||
ref: { | ||
divRef, | ||
}, | ||
}; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { render } from "extreme"; | ||
import { createComponent } from "extreme"; | ||
import template from "./index.html?raw"; | ||
|
||
export const Content = (element: HTMLElement) => { | ||
return render(element, template); | ||
}; | ||
export const Content = createComponent("Content", () => { | ||
return { template }; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { render } from "extreme"; | ||
import { createComponent } from "extreme"; | ||
import template from "./index.html?raw"; | ||
|
||
export const Topbar = (element: HTMLElement) => { | ||
return render(element, template, { | ||
export const Topbar = createComponent("Topbar", () => { | ||
return { | ||
template, | ||
state: { | ||
title: "topbar", | ||
}, | ||
}); | ||
}; | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.