@@ -26,11 +26,13 @@ import GlobalStyles from './GlobalStyles';
2626import { overrideECProps } from '../lib/overrideECProps' ;
2727
2828const EmbeddedChat = ( props ) => {
29- const [ config , setConfig ] = useState ( ( ) => props ) ;
29+ const [ remoteOverrides , setRemoteOverrides ] = useState ( { } ) ;
3030
31- useEffect ( ( ) => {
32- setConfig ( props ) ;
33- } , [ props ] ) ;
31+ const config = useMemo (
32+ ( ) => ( { ...props , ...remoteOverrides } ) ,
33+ // eslint-disable-next-line react-hooks/exhaustive-deps
34+ [ props , remoteOverrides ]
35+ ) ;
3436
3537 const {
3638 isClosable = false ,
@@ -52,14 +54,18 @@ const EmbeddedChat = (props) => {
5254 className = '' ,
5355 style = { } ,
5456 hideHeader = false ,
55- auth = {
56- flow : 'PASSWORD' ,
57- } ,
57+ auth : authProp = null ,
5858 secure = false ,
5959 dark = false ,
6060 remoteOpt = false ,
6161 } = config ;
6262
63+ const auth = useMemo (
64+ ( ) => authProp ?? { flow : 'PASSWORD' } ,
65+ // eslint-disable-next-line react-hooks/exhaustive-deps
66+ [ authProp ?. flow , authProp ?. credentials ]
67+ ) ;
68+
6369 const hasMounted = useRef ( false ) ;
6470 const { classNames, styleOverrides } = useComponentOverrides ( 'EmbeddedChat' ) ;
6571 const [ fullScreen , setFullScreen ] = useState ( false ) ;
@@ -208,7 +214,7 @@ const EmbeddedChat = (props) => {
208214
209215 if ( appInfo ) {
210216 const remoteConfig = appInfo . propConfig ;
211- setConfig ( ( prevConfig ) => overrideECProps ( prevConfig , remoteConfig ) ) ;
217+ setRemoteOverrides ( ( prev ) => overrideECProps ( prev , remoteConfig ) ) ;
212218 }
213219 } catch ( error ) {
214220 console . error ( 'Error fetching remote config:' , error ?. message || error ) ;
@@ -219,7 +225,7 @@ const EmbeddedChat = (props) => {
219225 if ( remoteOpt ) {
220226 getConfig ( ) ;
221227 }
222- } , [ RCInstance , remoteOpt , setConfig , setIsSynced ] ) ;
228+ } , [ RCInstance , remoteOpt , setIsSynced ] ) ;
223229
224230 const ECOptions = useMemo (
225231 ( ) => ( {
0 commit comments