Bug Description
When using ReactCusdis component, the i18n language settings fail after page refresh. The comment widget reverts to the default language (English) even when a specific language is configured via the lang prop.
Expected Behavior
The widget should display in the language specified by the lang prop consistently across page refreshes.
Actual Behavior
- First load works correctly with the specified language
- After page refresh, the widget falls back to English
- The issue appears to be caused by scripts loading in parallel without guaranteed order
Root Cause Analysis
The current implementation loads both the main script and language script in parallel:
useScript(`${host}/js/cusdis.es.js`)
useScript(props.lang ? `${host}/js/widget/lang/${props.lang}.js` : '')
This causes a race condition where:
- The language script may load and execute before the main script
- The main script may overwrite the language configuration when it loads later
- renderCusdis() may be called before the language script has fully initialized
Steps to Reproduce
- Use ReactCusdis component with lang="zh" (or any non-English language)
- Load the page initially → language works correctly
- Refresh the page → language resets to English
Bug Description
When using ReactCusdis component, the i18n language settings fail after page refresh. The comment widget reverts to the default language (English) even when a specific language is configured via the lang prop.
Expected Behavior
The widget should display in the language specified by the lang prop consistently across page refreshes.
Actual Behavior
Root Cause Analysis
The current implementation loads both the main script and language script in parallel:
This causes a race condition where:
Steps to Reproduce