Move suggested actions from Redux store to React hooks#5489
Merged
compulim merged 20 commits intomicrosoft:mainfrom May 30, 2025
Merged
Move suggested actions from Redux store to React hooks#5489compulim merged 20 commits intomicrosoft:mainfrom
compulim merged 20 commits intomicrosoft:mainfrom
Conversation
OEvgeny
reviewed
May 28, 2025
compulim
commented
May 29, 2025
compulim
commented
May 29, 2025
OEvgeny
reviewed
May 29, 2025
packages/test/page-object/src/globals/testHelpers/createDirectLineEmulator.js
Outdated
Show resolved
Hide resolved
compulim
commented
May 29, 2025
OEvgeny
reviewed
May 29, 2025
OEvgeny
reviewed
May 29, 2025
OEvgeny
approved these changes
May 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog Entry
Changed
useSuggestedActionsto use React hooks as backend instead of Redux store, in PR #5489, by @compulimDescription
In the future, we will deprecate the Redux store and move all state management into native React. This will enable us to work with the next generation of chat adapter which we incubated during our experimental work with Azure Communication Services.
The chat adapter work will make Web Chat cleaner on responsibility and reduce burden on handling different protocols.
This pull request is our first attempt to move suggested actions to React native state management, while keeping backward compatibility through data replication.
Design
Each area of concern will be hosted in their own React context. For instance,
suggestedActionsandsuggestedActionsOriginActivityis now in the new<SuggestedActionsComposer>.Data flow
Source of truth
The source of truth will be React context. This will help us to deprecate Redux store more easily in some future.
Redux action -> React context
All existing Redux action will be captured by "action sink" and sink into React context. The context component will then use React native state management (
useStateanduseReducer) to save the value.React context -> Redux action
When the state in React has changed, the new value will be replicated to Redux store via a special
WEB_CHAT_INTERNAL/*action.Data consumption
Our React hooks will start reading from React context, instead of Redux
useSelector(). The impact should be minimal as we should have enough tests to convert the surface area of our hooks. However, further minimize risks, we should continue to invest test on hooks.Data changes from React will be replicated to Redux, web developers can continue to run their apps based on Redux
dispatch()andgetState().Performance impact
As data will need to replicate from React to Redux, there will be both space and time penalty.
To minimize performance impact, web developers who do not use the Redux store can opt in and disable the data replication. This feature will be built in future pull requests.
Specific Changes
redux-storepackagesuggestedActionsreducer to the new<SuggestedActionsComposer>componentuseSuggestedActions()hook to use the new value from<SuggestedActionsComposer>componentreact-valibotpackage to housereactNodeandvalidatePropsCHANGELOG.mdReview Checklist
Accessibility reviewed (tab order, content readability, alt text, color contrast)Browser and platform compatibilities reviewedCSS styles reviewed (minimal rules, noz-index)Documents reviewed (docs, samples, live demo)Internationalization reviewed (strings, unit formatting)package.jsonandpackage-lock.jsonreviewedSecurity reviewed (no data URIs, check for nonce leak)