Skip to content

Commit

Permalink
Expanded basic example section
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Mar 8, 2018
1 parent 5b715e3 commit 7071975
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions text/0000-ref-forwarding.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,29 @@ function injectLegacyRelayContext(Component) {
}
```

The theme context wrapper could as well:

```js
const ThemeContext = React.createContext("light");

function withTheme(ThemedComponent) {
function ThemeContextInjector(props) {
return (
<ThemeContext.Consumer>
{value => (
<ThemedComponent {...props} ref={props.forwardedRef} theme={value} />
)}
</ThemeContext.Consumer>
);
}

// Forward refs through to the inner, "themed" component:
return React.useRef((props, ref) => (
<ThemeContextInjector {...props} forwardedRef={ref} />
));
}
```

# Detailed design

TODO
Expand Down

0 comments on commit 7071975

Please sign in to comment.