allenai / pdf-component-library

51 stars 5 forks source link

28926 subtask: ContextProvider console warning when setters aren't instantiated #20

Closed carolinepaulic closed 3 years ago

carolinepaulic commented 3 years ago

Description

This is a subtask of https://github.com/allenai/scholar/issues/28926 and a continuation of the state management work from https://github.com/allenai/scholar/issues/28332.

This PR replaces our previous (bogus) default context setter functions with a console warning that informs the user that the function they are calling hasn't been set up properly.

Example warning text: "Unable to call setNumPages(5). The DocumentContext Provider may not be set up correctly." (open to better copy if you have suggestions)

Reviewer Instructions

This was done to appease a TypeScript warning. I'm not sure how to trigger these warnings manually with the way the ContextProvider and our types are set up- open to suggestions if I'm missing something here.

Testing Plan

Run all unit tests locally.