Skip to main content

hoc

Wraps all components in a higher-order component.

// Components are automatically wrapped with `observer()`
import { store } from './store'

export default function App() {
  return (
    <button onClick={() => { store.counter++ }}>
      Counter {store.counter}
    </button>
  )
}

Installation

npm install react-beyond @react-beyond/hoc

Usage

import { Beyond } from 'react-beyond'
import { classFor } from '@react-beyond/clsx'

<Beyond features={[hoc(<options>)]}>
  <App />
</Beyond>

Options

The options parameter can either be an higher-order component function or an object with the following properties:

  • id - The id of the feature HOC. Defaults to "hoc".
  • hoc - The higher-order function in which to wrap the components.