Sitemap

Hoc-Pattern

1 min readMar 3, 2018

--

The HOC pattern is the oldest pattern, The pattern use have an HOC which is used to wrap a child component and provide all props to the child component.Now it has been replaced by renderProp Pattern as it is easy to understand and according to modern trends

Render-Prop-Pattern

This pattern is referred to by a number of different names:

  • render prop
  • render callback
  • function as child

Render Props

The idea behind this pattern is that you’ve to build a Stateful Component that wraps logic, the result of the execution of this logic is shared by a callback.

Get ADNAN NAEEM’s stories in your inbox

Join Medium for free to get updates from this writer.

This callback is a prop used by the component you build, and the prop is normally called render.

This pattern of composition also makes it easier to design components that have complex, conditional or nested children like some UI components

Summary:

Render Prop Pattern is helpful as it helps us to recognize props by name where as HOC passes props unnamed.They are one line function which is rendered as a child .It takes component as input and return components with props

--

--