From accea9b71c27e5507eb67ec06ad17c53d59e826c Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Tue, 10 Mar 2020 08:25:24 +0000 Subject: [PATCH] Travis build: 291 --- snippet_data/snippetList.json | 16 ++++++++++++++++ snippet_data/snippets.json | 26 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/snippet_data/snippetList.json b/snippet_data/snippetList.json index c2d043ad1..4b7aafce4 100644 --- a/snippet_data/snippetList.json +++ b/snippet_data/snippetList.json @@ -563,6 +563,22 @@ "hash": "82ef558fad661a522f5e897014b3898ad56ab6603a342c477f09edaa6281a0c9" } }, + { + "id": "useComponentWillUnmount", + "type": "snippetListing", + "title": "useComponentWillUnmount", + "attributes": { + "text": "A hook that executes a callback immediately before a component is unmounted and destroyed.\n\n- Use `React.useEffect()` with an empty array as the second argument and return the provided callback to be executed only once before cleanup.\n\n", + "tags": [ + "hooks", + "effect", + "beginner" + ] + }, + "meta": { + "hash": "dd2769c603f226996de8baf90af511fc788543dcb194a3b600f83fd2916699a6" + } + }, { "id": "useFetch", "type": "snippetListing", diff --git a/snippet_data/snippets.json b/snippet_data/snippets.json index 44be288f5..f2b2678df 100644 --- a/snippet_data/snippets.json +++ b/snippet_data/snippets.json @@ -903,6 +903,32 @@ "authorCount": 2 } }, + { + "id": "useComponentWillUnmount", + "title": "useComponentWillUnmount", + "type": "snippet", + "attributes": { + "fileName": "useComponentWillUnmount.md", + "text": "A hook that executes a callback immediately before a component is unmounted and destroyed.\n\n- Use `React.useEffect()` with an empty array as the second argument and return the provided callback to be executed only once before cleanup.\n\n", + "codeBlocks": { + "style": "", + "code": "const useComponentWillUnmount = onUnmountHandler => {\n React.useEffect(() => () => {\n onUnmountHandler()\n }, []);\n}", + "example": "const Unmounter = () => {\n useComponentWillUnmount(() => console.log('Component will unmount'));\n\n return