Skip to content

Commit

Permalink
fix: 导出 sketch 中的 hooks 方法
Browse files Browse the repository at this point in the history
  • Loading branch information
limaofeng committed Nov 17, 2021
1 parent 1999e66 commit 3e81ce9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Sunmao.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ class Sunmao {
if (component.tags) {
for (const tag of component.tags) {
let rootTags = this.tags;
// eslint-disable-next-line no-loop-func
tag.split('/').forEach((key, index, array) => {
let subTag = rootTags.find(({ id }) => id === key);
if (!subTag) {
rootTags.push((subTag = { id: key, value: key, label: key, children: [] }));
}
rootTags = subTag.children;
if (array.length == index + 1) {
if (array.length === index + 1) {
rootTags.push({
...root.info,
value: root.info.id,
Expand Down
1 change: 1 addition & 0 deletions src/sketch/BlockContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function buildBlockProvider(
)}
</BlockContext.Provider>
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);
}
);
Expand Down
3 changes: 3 additions & 0 deletions src/sketch/SketchContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export class Sketch {

on(eventName: SketchEventName, callback: EventCallback) {
this.emitter.on(eventName, callback);
return () => {
this.emitter.off(eventName, callback);
};
}

trigger(eventName: SketchEventName, ...params: any) {
Expand Down
1 change: 1 addition & 0 deletions src/sketch/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as ReactComponentProvider } from './ReactComponentProvider';
export { SketchProvider } from './SketchContext';
export * from './ReactComponentProvider';

0 comments on commit 3e81ce9

Please sign in to comment.