File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -272,6 +272,30 @@ const App = () => (
272272)
273273` ` `
274274
275+ #### Use ` createRender` to interop with a library which only supports function as render-prop
276+
277+ [](https://codesandbox.io/s/1qyqwq14jq)
278+
279+ ` ` ` js
280+ import Toggle from ' react-toggled'
281+
282+ const Toggler = ({on, getTogglerProps, onLabel, offLabel}) => (
283+ < div>
284+ < button {... getTogglerProps ()}> Toggle me< / button>
285+ < div> {on ? onLabel : offLabel}< / div>
286+ < / div>
287+ )
288+
289+ Toggler .defaultProps = {
290+ onLabel: ' Toggled On' ,
291+ offLabel: ' Toggled Off' ,
292+ }
293+
294+ const ToggleView = createRender (Toggler)
295+
296+ const App = () => < Toggle> {ToggleView}< / Toggle>
297+ ` ` `
298+
275299## Other Solutions
276300
277301- [` render- props` ](https://github.com/donavon/render-props)
You can’t perform that action at this time.
0 commit comments