Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(筆記)Toast Notification #129

Open
gracekrcx opened this issue Jun 18, 2022 · 1 comment
Open

(筆記)Toast Notification #129

gracekrcx opened this issue Jun 18, 2022 · 1 comment

Comments

@gracekrcx
Copy link
Owner

gracekrcx commented Jun 18, 2022

Portals

Portals
purpose:
A typical use case for portals is when a parent component has an overflow: hidden or z-index style, but you need the child to visually “break out” of its container. For example, dialogs, hovercards, and tooltips.

Ref

如何與 Portal interact 從 app component

  1. app component pass 一個 function 到 toast portal
  2. 如何讓 toast portal component 有一個 function 然後從 app component 去 call
    2.1 global 的方式:context or redux
    2.2
    -> use refs to communicate with our toast portal component
    ---> we want create a function inside toast portal that we to call using that ref in app component
    ---> the function that we want to call inside of toast portal from our app component is the ability to 『create a new toast』, we want the toast portal itself to house the function and house the toast's state 因為如果不這樣做 the app component would have to the component that manages the toast state and the function for adding toast
    ---> 是以設計成可以給別人使用的 library 去想

---> toast portal itself is what is managing that list of toasts

forwardRef

useImperativeHandle

closure

the way that useEffect works in tandem with like setTimeout

@gracekrcx
Copy link
Owner Author

Architecture

two components
one is toaster service or a toaster controller or toast portal
two is toaster component
and we will pass configuration into the toast portal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant