Browse Source

Updated forwardRef example to use named function

main
Brian Vaughn 7 years ago
parent
commit
22d0ec128e
  1. 2
      examples/16-3-release-blog-post/fancy-button-example.js
  2. 8
      examples/16-3-release-blog-post/forward-ref-example.js

2
examples/16-3-release-blog-post/fancy-button-example.js

@ -8,7 +8,7 @@ class FancyButton extends React.Component {
render() {
// highlight-next-line
const {label, theme, ...rest} = this.props;
// highlight-range{4}
// highlight-range{5}
return (
<button
{...rest}

8
examples/16-3-release-blog-post/forward-ref-example.js

@ -16,10 +16,12 @@ function withTheme(Component) {
}
// Intercept the "ref" and pass it as a custom prop.
// highlight-range{1-3}
return React.forwardRef((props, ref) => (
// highlight-range{1, 3}
return React.forwardRef(function forward(props, ref) {
return (
<ThemedComponent {...props} forwardedRef={ref} />
));
);
});
}
// highlight-next-line

Loading…
Cancel
Save