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

Version 1.2.0 #131

Merged
merged 7 commits into from
Jun 16, 2022
Merged

Version 1.2.0 #131

merged 7 commits into from
Jun 16, 2022

Conversation

nmanu1
Copy link
Contributor

@nmanu1 nmanu1 commented Jun 16, 2022

Version 1.2.0

Features

yen-tt and others added 7 commits May 25, 2022 14:20
This pr updates answers-headless-react to support React 18 as well as 17.

- use alpha version 1.1.1.-alpha.0-95 of answers-headless which contains redux package update to support React 18.
- to support react 18 concurrent mode, useSyncExternalStore is needed. This pr uses `use-sync-external-store` package for backwards-compatible with pre-18 versions (v17).
  - ~~From [internal doc](https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreShimServer.js#L15)s in `use-sync-external-store`, the package does not offer much logic to support the case of server side rendering for react pre-18 versions. So, this pr update useAnswersState to be conditionally exported with either `useAnswersStateWithManualStoreSync` for SSR pre-18 or `useAnswersStateWithReactStoreSync` for everything else.~~ updated to use `use-sync-external-store` as is, without the manual handling, for all cases ([for more info](#122 (comment))).
  - with v17 version, there's warnings for state update on unmounted components, which we do get for when an async function (execute universal/vertical search) finish and send a series of dispatch that would trigger a re-render of a component that's already unmounted. There's no actual memory leak here since we always unsubscribe out listeners. This warning was removed in v18 (visit this [PR](facebook/react#22114) for more details). As a workaround, `isMountedRef` is used in `useAnswersStateWithReactStoreSync` to track when a component is unmounted and prevent the callback for handlling store changes from triggering (cause component update).
  - update relevant packages to support v18 as well (`@testing-library/react`, `@types/react`)



Note: will release an alpha version of this for the component lib.

J=SLAP-2095
TEST=manual&auto
- added new jest tests for server side rendering and hydration process.
- see that jest tests passed successfully for V17 and V18. (note that @testing-library/react v13 drop support for 17 when beginning to support 18 in the same version)
- test (client side) with React version 17 and React version 18 in test-site from component lib repo.
  - with React verison 18. test with render (pre-18 syntax) and createRoot (18), ran a couple search and switch between universal and vertical page. see that both works as expected, although there is a warning for the former approach (`Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17.`) which is expected.
- test (SSR) with React version 17 and React version 18 with yext-site-starters repo. See that the assets were built successfully and the page function as expected.
fix headless package version
…ns (#124)

We support react 16.14 at latest - we do not support earlier versions of 16.
This is due to us using the newest jsx transform which was only added to 16.14 and not earlier versions of 16.
https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

We could make answers-headless-react support earlier versions of react by changing our jsx transform
However in [yext/answers-react-components](https://github.com/yext/answers-react-components) we also depend on restart/ui which requires 16.14. Lastly, we already knew that redux-toolkit requires 16.9, which is another barrier
to support 16.8.

J=SLAP-2113
TEST=manual,auto

hook up local headless-react to local answers-react-components test site using react 16.14
see the components work as expected, and the dev tools say that the components are rendered by react-dom@16.14.0
try running vertical + universal searches, using numerical facets, using hierarchical facets
Updates answers-headless to the next alpha version which now exports a
SandboxEndpoints object.

J=SLAP-2106
TEST=auto

added test for checking that an answers config is passed from AnswersHeadlessProvider
to provideAnswersHeadless without the endpoints being altered
This PR upgrades Jest from v27 to v28. Most of the breaking changes don't affect us, except for two:
- To use the JSDOM test environment, `jest-environment-jsdom` now has to be installed separately. But, this means a newer version of `jsdom` is used, which assumes there is a global `TextEncoder`, that is not provided by `jest-environment-jsdom`. This issue is fixed by re-exporting Node `util`'s `TextEncoder` as `global.TextEncoder` in `setup-env.ts`
- Jest now has full support for package exports, which can cause problems where file imports are not resolved correctly. Specifically, this is a problem for `uuid`. There is a discussion and proposed solution in this [GitHub issue](microsoft/accessibility-insights-web#5421 (comment)), which I used in this PR. To summarize, the fix is to add a custom resolver that forces Jest to use the CommonJS+node version of `uuid`, but leaves all other resolutions the same

J=SLAP-2123
TEST=auto

See that Jest tests pass.
Update the Headless version to v1.2.0
@nmanu1 nmanu1 requested a review from a team as a code owner June 16, 2022 20:28
@coveralls
Copy link

Coverage Status

Coverage increased (+9.2%) to 78.889% when pulling ebafe71 on release/v1.2 into af64369 on main.

@nmanu1 nmanu1 merged commit 88e48dd into main Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants