This converts the implementation of QuerySelect to a React functional component which makes it usable with hooks. Additionally, this introduces a new autoInit prop that allows for users to skip initialization. This is most useful in test environments where, in general, we don't want this component to be initializing and making requests. I explored an alternative solution where this utilizes the query APIWrapper, however, as expected this still requires significant mocking/fixturing to get working in all cases which isn't worth the investment as this time.
The autoInit property defaults to false in test environments and I'm seeing ~25% reduction in total test time in CI for this package.
Rationale
This converts the implementation of
QuerySelect
to a React functional component which makes it usable with hooks. Additionally, this introduces a newautoInit
prop that allows for users to skip initialization. This is most useful in test environments where, in general, we don't want this component to be initializing and making requests. I explored an alternative solution where this utilizes the query APIWrapper, however, as expected this still requires significant mocking/fixturing to get working in all cases which isn't worth the investment as this time.The
autoInit
property defaults to false in test environments and I'm seeing ~25% reduction in total test time in CI for this package.Related Pull Requests
Changes
QuerySelect
autoInit
variable that allows for users to skip initialization. This is most useful in test environments.autoInit
toprocess.env.NODE_ENV !== 'test'