|
@@ -13,17 +13,18 @@ declare global {
|
|
|
* Retrieves the React instance that this package should use.
|
|
* Retrieves the React instance that this package should use.
|
|
|
*
|
|
*
|
|
|
* - **Production Mode**: Returns the React instance from `window.GrowiFacade.react`
|
|
* - **Production Mode**: Returns the React instance from `window.GrowiFacade.react`
|
|
|
- * to ensure consistency with GROWI's main React version.
|
|
|
|
|
|
|
+ * to ensure a single shared React instance across the app.
|
|
|
* - **Development Mode**: Returns the React instance passed as an argument,
|
|
* - **Development Mode**: Returns the React instance passed as an argument,
|
|
|
- * which typically allows local/hot reload development without conflicts.
|
|
|
|
|
|
|
+ * which allows local development and hot reload without issues.
|
|
|
*
|
|
*
|
|
|
* @param react - The React instance to use during development
|
|
* @param react - The React instance to use during development
|
|
|
* @returns A React instance to be used in the current environment
|
|
* @returns A React instance to be used in the current environment
|
|
|
*
|
|
*
|
|
|
* @remarks
|
|
* @remarks
|
|
|
- * This approach prevents bundling multiple React versions and avoids Hook conflicts.
|
|
|
|
|
- * Make sure the `window.GrowiFacade.react` object is set before calling this function
|
|
|
|
|
- * in a production environment.
|
|
|
|
|
|
|
+ * Using multiple React instances in a single app can cause serious issues,
|
|
|
|
|
+ * especially with features like Hooks, which rely on a consistent internal state.
|
|
|
|
|
+ * This function ensures that only one React instance is used in production
|
|
|
|
|
+ * to avoid such problems.
|
|
|
*/
|
|
*/
|
|
|
export const growiReact = (react: typeof React): typeof React => {
|
|
export const growiReact = (react: typeof React): typeof React => {
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
if (process.env.NODE_ENV === 'production') {
|