Skip to content

Commit

Permalink
modified react/use-observable-value description
Browse files Browse the repository at this point in the history
  • Loading branch information
timchen10001 committed Nov 3, 2021
1 parent d190367 commit c6ed296
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions use-observable-value.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

> 想法:
1. 較高層級的資料結構只需要,把所有的子元件 onMount 出來,然後每個子元件在 生命週期建立時,透過 ```EventEmitter``` 進行狀態監聽以及通知,透過 ```Observable``` 進行狀態更新時的行為。
1. 較高層級的資料結構只需要,把所有的子元件 onMount 出來,然後每個子元件在 生命週期建立時,透過 ```EventEmitter``` 進行狀態監聽以及通知,透過 ```Observable``` 進行狀態更新時的行為。

2. 透過 ```EventEmitter``` 幫忙監聽狀態,當對應的子元件有狀態變動,可以透過 ```EventEmitter``` 主動通知 ```Observable``` 去更新重渲染對到的元件。因此每個 子元件 都有獨立的狀態 scope,不需要仰賴高層級的元件重繪,達成低層級的狀態更新。

Expand Down Expand Up @@ -122,7 +122,7 @@ export function useIsSelected(selectorId: string) {
});

return () => {
subscription.unsubscribe();
subscription.unsubscribe(); // componentWillUnMount 要取消狀態訂閱狀態,以免發生 memory leak 的狀況。
};
}, [selectionId]);

Expand Down

0 comments on commit c6ed296

Please sign in to comment.