Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 931 Bytes

render-callback.md

File metadata and controls

27 lines (21 loc) · 931 Bytes
id sidebar_label title description keywords version image
render-callback
Render callback
Render Callback
Render callback | React Patterns, techniques, tips and tricks in development for React developers.
render callback
reactpatterns
react patterns
reactjspatterns
reactjs patterns
react
reactjs
react techniques
react tips and tricks
Render callback
/img/reactpatterns-cover.png

For example below, notice that we create a function foo which takes a callback function as a parameter. When we call foo, it turns around and calls back to the passed-in function.

const foo = (hello) => {
  return hello('foo')
}

foo((name) => {
  return `hello from ${name}`
})

// hello from foo

As you can see, foo used the callback function to complete a portion of a string.

In the React world, a render callback works the same way, but returning a portion of the rendered markup.