jitsi-meet/react/features/app/functions.any.js
Lyubo Marinov bd7c9473e7 [Android] Fix possible TypeError in multi-JitsiMeetView SDK consumers
If multiple JitsiMeetView instances are created (not necessarily
existing at once), it's possible to hit a TypeError when reading the
React Component props of the currently mounted App. Anyway, in certain
places we're already protecting against that out of abundance of caution
so it makes no sense to not protect everywhere.
2018-05-09 23:45:24 -05:00

29 lines
768 B
JavaScript

// @flow
import { toState } from '../base/redux';
/**
* Gets the value of a specific React {@code Component} prop of the currently
* mounted {@link App}.
*
* @param {Function|Object} stateful - The redux store or {@code getState}
* function.
* @param {string} propName - The name of the React {@code Component} prop of
* the currently mounted {@code App} to get.
* @returns {*} The value of the specified React {@code Compoennt} prop of the
* currently mounted {@code App}.
*/
export function getAppProp(stateful: Function | Object, propName: string) {
const state = toState(stateful)['features/app'];
if (state) {
const { app } = state;
if (app) {
return app.props[propName];
}
}
return undefined;
}