Skip to content

Implement React context provider #105

@drborges

Description

@drborges

In some cases it may be convenient to be able to share a store via context provider while keeping the rest of the application decoupled from how and where the store comes from:

const store1 = new Arbor<Todo[]>([])
const store2 = new Arbor<Todo[]>([])


function App1() {
  return (
    <Provider value={store1}>
      <MyApp />
    </Provider>
  )
}

function App2() {
  return (
    <Provider value={store2}>
      <MyApp />
    </Provider>
  )
}

function MyApp() {
  const todos = useArborContext<Todo[]>()
  ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    arbor-reactIssues specific to the @arborjs/react package

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions