Skip to content

Commit b17e485

Browse files
author
Nicolas Garnier
committed
Added a callback to the ui instance
1 parent c875b1c commit b17e485

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,26 @@ class SignInScreen extends React.Component {
134134
}
135135
```
136136

137+
### Accessing the FirebaseUI instance
138+
139+
To allow for further configuration you can access the firebaseUI instance before it is started.
140+
To do this you can pass a `uiCallback` callback function that wil be passed the Firebase UI instance. For example here is how to enable the `disableAutoSignIn()` option:
141+
142+
```js
143+
// ...
144+
145+
render() {
146+
return (
147+
<div>
148+
<h1>My App</h1>
149+
<p>Please sign-in:</p>
150+
<FirebaseAuth uiCallback={ui => ui.disableAutoSignIn()} uiConfig={this.uiConfig} firebaseAuth={firebase.auth()}/>
151+
</div>
152+
);
153+
}
154+
```
155+
156+
137157
## Packing your app
138158

139159
The `FirebaseAuth` component needs a global CSS to get proper styling. The CSS is already imported within `FirebaseAuth`.

src/FirebaseAuth.jsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export default class FirebaseAuth extends React.Component {
5353
if (this.uiConfig.signInFlow === 'popup') {
5454
this.firebaseUiWidget.reset();
5555
}
56+
if (this.uiCallback) {
57+
this.uiCallback(this.firebaseUiWidget);
58+
}
5659
this.firebaseUiWidget.start('#' + this.elementId, this.uiConfig);
5760
}
5861

@@ -67,11 +70,18 @@ export default class FirebaseAuth extends React.Component {
6770
* Properties types.
6871
*/
6972
props: {
70-
uiConfig: Object, // The Firebase UI Web UI Config object.
71-
// See: https://github.com/firebase/firebaseui-web#configuration
72-
firebaseAuth: Object, // The Firebase App auth instance to use.
73-
elementId?: String, // The ID of the underlying container that we'll generate.
74-
// Use this if you use more than one instance at a time in your app.
73+
// The Firebase UI Web UI Config object.
74+
// See: https://github.com/firebase/firebaseui-web#configuration
75+
uiConfig: Object,
76+
// The Firebase App auth instance to use.
77+
firebaseAuth: Object,
78+
// The ID of the underlying container that we'll generate.
79+
// Use this if you use more than one instance at a time in your app.
80+
elementId?: String,
81+
// Callback that will be passed the FirebaseUi instance before it is
82+
// started. This allows access to certain configuration options such as
83+
// disableAutoSignIn().
84+
uiCallback?: Function,
7585
className: String
7686
};
7787

0 commit comments

Comments
 (0)