Skip to content

Create a context to access props in nested components #35

@mrdotb

Description

@mrdotb

Having a context will be usefull when you are dealing with nested component which avoid to do props drilling to get live_view callback.
https://github.com/mrdotb/live_react/blob/main/assets/js/live_react/hooks.js#L23

import { useLiveReact } from 'live_react'

export const Component = () => {
  const { pushEvent } = useLiveReact
  // ...
}

Then should the component be wrapped automatically or should it be the user responsibility to wrap his component with the live_react context 🤔

import { LiveReactProvider } from 'live_react'

<LiveReactProvider>
 // ...
</LiveReactProvider>

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions