feat(rnsdk) share bootsrap code with app

This commit is contained in:
Saúl Ibarra Corretgé
2023-07-31 15:39:08 +02:00
committed by Saúl Ibarra Corretgé
parent 38280c358f
commit c83c4488bf
4 changed files with 30 additions and 23 deletions

View File

@@ -1,10 +1,7 @@
/* eslint-disable lines-around-comment, no-undef, no-unused-vars */
import 'react-native-gesture-handler';
// Apply all necessary polyfills as early as possible
// to make sure anything imported henceforth sees them.
import 'react-native-get-random-values';
import './react/features/mobile/polyfills';
// NB: This import must always come first.
import './react/bootstrap.native';
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
import { View, ViewStyle } from 'react-native';
@@ -12,7 +9,6 @@ import { View, ViewStyle } from 'react-native';
import { appNavigate } from './react/features/app/actions.native';
import { App } from './react/features/app/components/App.native';
import { setAudioMuted, setVideoMuted } from './react/features/base/media/actions';
import JitsiThemePaperProvider from './react/features/base/ui/components/JitsiThemeProvider.native';
interface IEventListeners {
@@ -117,11 +113,9 @@ export const JitsiMeeting = forwardRef((props: IAppProps, ref) => {
return (
<View style = { style as ViewStyle }>
<JitsiThemePaperProvider>
<App
{ ...appProps }
ref = { app } />
</JitsiThemePaperProvider>
<App
{ ...appProps }
ref = { app } />
</View>
);
});

7
react/bootstrap.native.js vendored Normal file
View File

@@ -0,0 +1,7 @@
// https://github.com/software-mansion/react-native-gesture-handler/issues/320#issuecomment-443815828
import 'react-native-gesture-handler';
// Apply all necessary polyfills as early as possible to make sure anything imported henceforth
// sees them.
import 'react-native-get-random-values';
import './features/mobile/polyfills';

View File

@@ -12,6 +12,7 @@ import { getFeatureFlag } from '../../base/flags/functions';
import { clientResized, setSafeAreaInsets } from '../../base/responsive-ui/actions';
import DimensionsDetector from '../../base/responsive-ui/components/DimensionsDetector.native';
import { updateSettings } from '../../base/settings/actions';
import JitsiThemePaperProvider from '../../base/ui/components/JitsiThemeProvider.native';
import { _getRouteToRender } from '../getRouteToRender.native';
import logger from '../logger';
@@ -89,6 +90,20 @@ export class App extends AbstractApp<IProps> {
logger.info(`Loaded SDK ${AppInfo.sdkVersion}${liteTxt}`);
}
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
return (
<JitsiThemePaperProvider>
{ super.render() }
</JitsiThemePaperProvider>
);
}
/**
* Initializes feature flags and updates settings.
*

View File

@@ -1,17 +1,11 @@
// https://github.com/software-mansion/react-native-gesture-handler/issues/320#issuecomment-443815828
import 'react-native-gesture-handler';
// Apply all necessary polyfills as early as possible to make sure anything imported henceforth
// sees them.
import 'react-native-get-random-values';
import './features/mobile/polyfills';
// NB: This import must always come first.
import './bootstrap.native';
import React, { PureComponent } from 'react';
import { AppRegistry } from 'react-native';
import { App } from './features/app/components/App.native';
import { _initLogging } from './features/base/logging/functions';
import JitsiThemePaperProvider from './features/base/ui/components/JitsiThemeProvider';
/**
* React Native doesn't support specifying props to the main/root component (in
@@ -29,10 +23,7 @@ class Root extends PureComponent {
*/
render() {
return (
<JitsiThemePaperProvider>
<App
{ ...this.props } />
</JitsiThemePaperProvider>
<App { ...this.props } />
);
}
}