brainly / style-guide

:art: Brainly Front-End Style Guide
https://styleguide.brainly.com/
Other
163 stars 30 forks source link

Use React Context API for detecting nested components, ie. in Dialog component #2795

Open matzimowski opened 10 months ago

matzimowski commented 10 months ago

instead of accessing DOM to find nested components, ie:

const isNestedDialog = overlayRef.current?.parentElement?.closest(DIALOG_SELECTOR);

use React Context API

good read: https://www.aleksandrhovhannisyan.com/blog/react-context-nested-components/