Skip to content

Commit d0ff912

Browse files
committed
forwarding-refs: concrete example for function name
1 parent 1fe2e0a commit d0ff912

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

content/docs/forwarding-refs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ For example, the following component will appear as "*ForwardRef*" in the DevToo
6767

6868
`embed:forwarding-refs/wrapped-component.js`
6969

70-
If you name the render function, DevTools will also include its name (e.g. "*ForwardRef(myFunction)*"):
70+
If you name the render function, DevTools will also include its name (e.g. "*ForwardRef(Button)*"):
7171

7272
`embed:forwarding-refs/wrapped-component-with-function-name.js`
7373

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
const WrappedComponent = React.forwardRef(
2-
function myFunction(props, ref) {
3-
return <LogProps {...props} forwardedRef={ref} />;
1+
const FancyButton = React.forwardRef(
2+
function Button(props, ref) {
3+
return (
4+
<button ref={ref} className="FancyButton">
5+
{props.children}
6+
</button>
7+
);
48
}
59
);
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
const WrappedComponent = React.forwardRef((props, ref) => {
2-
return <LogProps {...props} forwardedRef={ref} />;
1+
const FancyButton = React.forwardRef((props, ref) => {
2+
return (
3+
<button ref={ref} className="FancyButton">
4+
{props.children}
5+
</button>
6+
);
37
});

0 commit comments

Comments
 (0)