Toru Kobayashi
7 years ago
6 changed files with 44 additions and 11 deletions
@ -0,0 +1,17 @@ |
|||
function logProps(Component) { |
|||
class LogProps extends React.Component { |
|||
// ...
|
|||
} |
|||
|
|||
function forwardRef(props, ref) { |
|||
return <LogProps {...props} forwardedRef={ref} />; |
|||
} |
|||
|
|||
// Give this component a more helpful display name in DevTools.
|
|||
// e.g. "ForwardRef(logProps(MyComponent))"
|
|||
// highlight-range{1-2}
|
|||
const name = Component.displayName || Component.name; |
|||
forwardRef.displayName = `logProps(${name})`; |
|||
|
|||
return React.forwardRef(forwardRef); |
|||
} |
@ -0,0 +1,5 @@ |
|||
const WrappedComponent = React.forwardRef( |
|||
function myFunction(props, ref) { |
|||
return <LogProps {...props} forwardedRef={ref} />; |
|||
} |
|||
); |
@ -0,0 +1,3 @@ |
|||
const WrappedComponent = React.forwardRef((props, ref) => { |
|||
return <LogProps {...props} forwardedRef={ref} />; |
|||
}); |
Loading…
Reference in new issue