Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add on-demand state retrieval via a ref from global-context-store's <Store /> #521

Closed
pringshia opened this issue Aug 19, 2021 · 0 comments · Fixed by #570
Closed

Add on-demand state retrieval via a ref from global-context-store's <Store /> #521

pringshia opened this issue Aug 19, 2021 · 0 comments · Fixed by #570
Assignees
Labels

Comments

@pringshia
Copy link
Contributor

Overview

In certain integration use-cases, we could have a container app that needs to handle the submission for an embedded annotation-toolkit app.

On submission, we need to allow the parent or sibling component to get access to the state of the annotation-toolkit application.

Proposal

Our proposal for doing so is via React refs. This will allow on-demand state-retrieval functionality using forwardRef and useImperativeHandle.

Motivating Use Case

We'd like to be able to do something like the below where on an event such as a button click, we can retrieve the current state of the annotation-toolkit app.

function handleSubmit(state) {
  console.log(state)
}

function ParentApp() {
  const appRef = useRef();
  return (
    <div>
      <button onClick={ () => handleSubmit(appRef.current.getState()) } />
      <EmbeddedApp ref={appRef} />
    </div>
  );
}

Design & Considerations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant