From fa756b52f3e621726496361d6eb8b2bf6999efdf Mon Sep 17 00:00:00 2001 From: Pruthuvi Fernando <86036451+Pruthuvi9@users.noreply.github.com> Date: Mon, 1 Dec 2025 19:52:19 +0530 Subject: [PATCH] Add a comment regarding using 'ref' property. Using 'ref' directly is not allowed as it it a special prop (along with 'key') in React which cannot be forwarded to the component. See here https://react.dev/warnings/special-props --- src/content/5/en/part5b.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/content/5/en/part5b.md b/src/content/5/en/part5b.md index abc37d6d68..6e69751b73 100644 --- a/src/content/5/en/part5b.md +++ b/src/content/5/en/part5b.md @@ -374,6 +374,7 @@ const App = () => { const noteFormRef = useRef() // highlight-line const noteForm = () => ( +// (Using 'ref' throws an error. According to this, https://react.dev/warnings/special-props, 'ref' and 'key' "are two special props which are used by React, and are thus not forwarded to the component". It should be renamed to something else.) // highlight-line @@ -401,6 +402,7 @@ const Togglable = (props) => { // highlight-line } // highlight-start +// It should be renamed here too useImperativeHandle(props.ref, () => { return { toggleVisibility } })