diff --git a/text/0000-callback-ref-cleanup.md b/text/0000-callback-ref-cleanup.md new file mode 100644 index 00000000..76b329ed --- /dev/null +++ b/text/0000-callback-ref-cleanup.md @@ -0,0 +1,242 @@ +- Start Date: 2021-09-08 +- RFC PR: https://github.com/reactjs/rfcs/pull/205 +- React Issue: https://github.com/facebook/react/issues/15176 + +# Summary + +Callback Refs should allow returning a cleanup function which will be called when the ref is removed or changed. + +# Basic example + +```jsx +function MyComponent(props) { + const exampleCallbackRef = useCallback((el) => { + /* effect code */ + return () => { /* cleanup code */ }; + }, []) + + return