Skip to content

Commit 9612d40

Browse files
authored
v3.0.0-alpha.14
* fix(types): add support for `React.FunctionalComponent` in `firebaseConnect`/`firestoreConnect` type definitions - @illuminist * fix(firebaseConnect): move hoistStatics to allow static methods to copied - @jeloagnasin * refactor(core): use JS formatted eslint config file - @Shalinit3 * fix(types): add any other values to UserProfile type * fix(examples): update typescript example
1 parent 068ad3f commit 9612d40

File tree

170 files changed

+42937
-30122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+42937
-30122
lines changed

.eslintrc

Lines changed: 0 additions & 24 deletions
This file was deleted.

.eslintrc.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = {
2+
root: true,
3+
4+
parser: 'babel-eslint',
5+
6+
extends: ['standard', 'standard-react', 'prettier', 'prettier/react'],
7+
plugins: ['babel', 'react', 'prettier'],
8+
9+
settings: {
10+
react: {
11+
version: 'detect'
12+
}
13+
},
14+
15+
env: {
16+
browser: true,
17+
es6: true
18+
},
19+
20+
rules: {
21+
semi: [2, 'never'],
22+
'no-console': 'error',
23+
'prettier/prettier': ['error', {
24+
singleQuote: true,
25+
trailingComma: 'none',
26+
semi: false,
27+
bracketSpacing: true,
28+
jsxBracketSameLine: true,
29+
printWidth: 80,
30+
tabWidth: 2,
31+
useTabs: false
32+
}]
33+
}
34+
};
35+

CONTRIBUTING.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ We welcome any type of contribution, not only code. You can help with
99
- **Marketing**: writing blog posts, howto's, printing stickers, ...
1010
- **Community**: presenting the project at meetups, organizing a dedicated meetup for the local community, ...
1111
- **Code**: take a look at the [open issues](issues). Even if you can't write code, commenting on them, showing that you care about a given issue matters. It helps us triage them.
12-
- **Money**: we welcome financial contributions in full transparency on our [open collective](https://opencollective.com/react-redux-firebase).
12+
- **Money**: we welcome financial contributions as detailed in the [financial contributions section](#financial-contributions).
1313

1414
## Your First Contribution
1515

@@ -26,8 +26,7 @@ It is also always helpful to have some context for your pull request. What was t
2626

2727
## Financial contributions
2828

29-
We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/react-redux-firebase).
30-
Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed.
29+
Financial contributions are welcomed through either [patreon](https://www.patreon.com/prescottprue) or [open collective](https://opencollective.com/react-redux-firebase).
3130

3231
## Questions
3332

@@ -48,20 +47,3 @@ Thank you to all our backers! [[Become a backer](https://opencollective.com/reac
4847

4948
<a href="https://opencollective.com/react-redux-firebase#backers" target="_blank"><img src="https://opencollective.com/react-redux-firebase/backers.svg?width=890"></a>
5049

51-
52-
### Sponsors
53-
54-
Thank you to all our sponsors! (please ask your company to also support this open source project by [becoming a sponsor](https://opencollective.com/react-redux-firebase#sponsor))
55-
56-
<a href="https://opencollective.com/react-redux-firebase/sponsor/0/website" target="_blank"><img src="https://opencollective.com/react-redux-firebase/sponsor/0/avatar.svg"></a>
57-
<a href="https://opencollective.com/react-redux-firebase/sponsor/1/website" target="_blank"><img src="https://opencollective.com/react-redux-firebase/sponsor/1/avatar.svg"></a>
58-
<a href="https://opencollective.com/react-redux-firebase/sponsor/2/website" target="_blank"><img src="https://opencollective.com/react-redux-firebase/sponsor/2/avatar.svg"></a>
59-
<a href="https://opencollective.com/react-redux-firebase/sponsor/3/website" target="_blank"><img src="https://opencollective.com/react-redux-firebase/sponsor/3/avatar.svg"></a>
60-
<a href="https://opencollective.com/react-redux-firebase/sponsor/4/website" target="_blank"><img src="https://opencollective.com/react-redux-firebase/sponsor/4/avatar.svg"></a>
61-
<a href="https://opencollective.com/react-redux-firebase/sponsor/5/website" target="_blank"><img src="https://opencollective.com/react-redux-firebase/sponsor/5/avatar.svg"></a>
62-
<a href="https://opencollective.com/react-redux-firebase/sponsor/6/website" target="_blank"><img src="https://opencollective.com/react-redux-firebase/sponsor/6/avatar.svg"></a>
63-
<a href="https://opencollective.com/react-redux-firebase/sponsor/7/website" target="_blank"><img src="https://opencollective.com/react-redux-firebase/sponsor/7/avatar.svg"></a>
64-
<a href="https://opencollective.com/react-redux-firebase/sponsor/8/website" target="_blank"><img src="https://opencollective.com/react-redux-firebase/sponsor/8/avatar.svg"></a>
65-
<a href="https://opencollective.com/react-redux-firebase/sponsor/9/website" target="_blank"><img src="https://opencollective.com/react-redux-firebase/sponsor/9/avatar.svg"></a>
66-
67-
<!-- This `CONTRIBUTING.md` is based on @nayafia's template https://github.com/nayafia/contributing-template -->

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ The [Material Example](https://github.com/prescottprue/react-redux-firebase/tree
2121

2222
## Features
2323

24-
- Out of the box support for authentication (with auto load user profile)
25-
- Full Firebase Platform Support Including Real Time Database, Firestore, and Storage
26-
- Automatic binding/unbinding of listeners through React Higher Order Components (`firebaseConnect` and `firestoreConnect`)
27-
- [Population capability](http://react-redux-firebase.com/docs/populate) (similar to mongoose's `populate` or SQL's `JOIN`)
28-
- Support small data ( using `value` ) or large datasets ( using `child_added`, `child_removed`, `child_changed` )
29-
- Multiple queries types supported including `orderByChild`, `orderByKey`, `orderByValue`, `orderByPriority`, `limitToLast`, `limitToFirst`, `startAt`, `endAt`, `equalTo`
30-
- Tons of examples of integrations including [`redux-thunk`](https://github.com/gaearon/redux-thunk) and [`redux-observable`](https://redux-observable.js.org/)
31-
- Server Side Rendering Support
32-
- [`react-native` support](http://react-redux-firebase.com/docs/integrations/react-native.html) using [native modules](http://react-redux-firebase.com/docs/integrations/react-native.html#native-modules) or [web sdk](http://react-redux-firebase.com/docs/integrations/react-native.html#jsweb)
24+
* Out of the box support for authentication (with auto load user profile)
25+
* Full Firebase Platform Support Including Real Time Database, Firestore, and Storage
26+
* Automatic binding/unbinding of listeners through React Higher Order Components (`firebaseConnect` and `firestoreConnect`)
27+
* [Population capability](http://react-redux-firebase.com/docs/populate) (similar to mongoose's `populate` or SQL's `JOIN`)
28+
* Support small data ( using `value` ) or large datasets ( using `child_added`, `child_removed`, `child_changed` )
29+
* Multiple queries types supported including `orderByChild`, `orderByKey`, `orderByValue`, `orderByPriority`, `limitToLast`, `limitToFirst`, `startAt`, `endAt`, `equalTo`
30+
* Tons of examples of integrations including [`redux-thunk`](https://github.com/gaearon/redux-thunk) and [`redux-observable`](https://redux-observable.js.org/)
31+
* Server Side Rendering Support
32+
* [`react-native` support](http://react-redux-firebase.com/docs/integrations/react-native.html) using [native modules](http://react-redux-firebase.com/docs/integrations/react-native.html#native-modules) or [web sdk](http://react-redux-firebase.com/docs/integrations/react-native.html#jsweb)
3333

3434
## Installation
3535

@@ -64,7 +64,7 @@ const fbConfig = {}
6464

6565
// react-redux-firebase config
6666
const rrfConfig = {
67-
userProfile: 'users',
67+
userProfile: 'users'
6868
// useFirestoreForProfile: true // Firestore for Profile instead of Realtime DB
6969
}
7070

@@ -77,7 +77,7 @@ firebase.initializeApp(fbConfig)
7777

7878
// Add firebase to reducers
7979
const rootReducer = combineReducers({
80-
firebase: firebaseReducer,
80+
firebase: firebaseReducer
8181
// firestore: firestoreReducer // <- needed if using firestore
8282
})
8383

@@ -103,7 +103,7 @@ function App() {
103103
);
104104
}
105105

106-
render(<App/>, document.getElementById('root'));
106+
render(<App />, document.getElementById('root'))
107107
```
108108

109109
The Firebase instance can then be grabbed from context within your components (`withFirebase` and `firebaseConnect` Higher Order Components provided to help):
@@ -176,8 +176,8 @@ export default compose(
176176
firebaseConnect(() => [
177177
'todos' // { path: '/todos' } // object notation
178178
]),
179-
connect((state) => ({
180-
todos: state.firebase.data.todos,
179+
connect(state => ({
180+
todos: state.firebase.data.todos
181181
// profile: state.firebase.profile // load profile
182182
}))
183183
)(Todos)
@@ -197,10 +197,10 @@ import { compose, withHandlers } from 'recompose'
197197

198198
// Component enhancer that loads todo into redux then into the todo prop
199199
const enhance = compose(
200-
firebaseConnect((props) => {
200+
firebaseConnect(props => {
201201
// Set listeners based on props (prop is route parameter from react-router in this case)
202202
return [
203-
{ path: `todos/${props.params.todoId}` }, // create todo listener
203+
{ path: `todos/${props.params.todoId}` } // create todo listener
204204
// `todos/${props.params.todoId}` // equivalent string notation
205205
]
206206
}),
@@ -232,7 +232,6 @@ function Todo({ todo }) {
232232
export default enhance(Todo)
233233
```
234234

235-
236235
**Load Data On Click**
237236

238237
```jsx
@@ -294,6 +293,7 @@ If you plan to use Firestore, you should checkout [`redux-firestore`][redux-fire
294293
Currently `react-redux-firebase` still handles auth when using [`redux-firestore`][redux-firestore] - The future plan is to also have auth standalone auth library that will allow the developer to choose which pieces they do/do not want.
295294

296295
## [Docs](http://react-redux-firebase.com)
296+
297297
See full documentation at [react-redux-firebase.com](http://react-redux-firebase.com)
298298

299299
* [Getting Started](http://react-redux-firebase.com/docs/getting_started)
@@ -306,6 +306,7 @@ See full documentation at [react-redux-firebase.com](http://react-redux-firebase
306306
## [Examples](examples)
307307

308308
### Real World Applications
309+
309310
* [fireadmin.io](http://fireadmin.io) - Firebase Instance Management Tool (source [available here](https://github.com/prescottprue/fireadmin))
310311

311312
If you would like a project added to this section please reach out [over gitter][gitter-url]
@@ -328,7 +329,7 @@ A simple example that was created using [create-react-app](https://github.com/fa
328329

329330
#### [Material App Example](examples/complete/material)
330331

331-
An example that user Material UI built on top of the output of [create-react-app](https://github.com/facebookincubator/create-react-app)'s eject command. Shows a list of todo items and allows you to add to them. This is what is deployed to [redux-firebasev3.firebaseapp.com](https://redux-firebasev3.firebaseapp.com/).
332+
An example that user Material UI built on top of the output of [create-react-app](https://github.com/facebookincubator/create-react-app)'s eject command. Shows a list of todo items and allows you to add to them. This is what is deployed to [redux-firebasev3.firebaseapp.com](https://redux-firebasev3.firebaseapp.com/).
332333

333334
## Discussion
334335

bin/api-docs-upload.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,16 @@ function uploadList(files) {
7474
)
7575
}
7676

77-
;(async function() {
78-
try {
79-
await runCommand('gsutil') // check for existence of gsutil
80-
await uploadList(first)
81-
await uploadList(second)
82-
console.log('Docs uploaded successfully') // eslint-disable-line no-console
83-
process.exit(0)
84-
} catch (err) {
85-
console.log('Error uploading docs:', err.message) // eslint-disable-line no-console
86-
process.exit(1)
87-
}
77+
;(function() {
78+
runCommand('gsutil') // check for existence of gsutil
79+
.then(() => uploadList(first))
80+
.then(() => uploadList(second))
81+
.then(() => {
82+
console.log('Docs uploaded successfully') // eslint-disable-line no-console
83+
process.exit(0)
84+
})
85+
.catch(err => {
86+
console.log('Error uploading docs:', err.message) // eslint-disable-line no-console
87+
process.exit(1)
88+
})
8889
})()

docs/api/constants.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ Default configuration options
8181

8282
- `userProfile` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** `null` Location on Firebase where user
8383
profiles are stored. Often set to `'users'`.
84+
- `profileFactory` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** `null` Function for changing how profile is written
85+
to database (both RTDB and Firestore).
8486
- `presence` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function))** `null` Location on Firebase where of currently
8587
online users is stored. Often set to `'presence'` or `'onlineUsers'`. If a function
8688
is passed, the arguments are: `(currentUser, firebase)`.
@@ -144,7 +146,7 @@ Default configuration options
144146
state (name given when passing reducer to combineReducers). Used in
145147
firebaseAuthIsReady promise (see
146148
[#264](https://github.com/prescottprue/react-redux-firebase/issues/264)).
147-
- `attachAuthIsReady` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` Whether or not to attach
149+
- `attachAuthIsReady` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `false` Whether or not to attach
148150
firebaseAuthIsReady to store. authIsLoaded can be imported and used
149151
directly instead based on preference.
150152
- `firestoreNamespace` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `firestoreHelpers` Namespace for

docs/api/firebaseConnect.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ needing to access a firebase instance created under a different store key.
2323
_Basic_
2424

2525
```javascript
26-
// this.props.firebase set on App component as firebase object with helpers
26+
// props.firebase set on App component as firebase object with helpers
2727
import { createFirebaseConnect } from 'react-redux-firebase'
2828
// create firebase connect that uses another redux store
2929
const firebaseConnect = createFirebaseConnect('anotherStore')
@@ -59,6 +59,7 @@ export default firebaseConnect()(App)
5959
_Ordered Data_
6060

6161
```javascript
62+
import React from 'react'
6263
import { compose } from 'redux'
6364
import { connect } from 'react-redux'
6465
import { firebaseConnect } from 'react-redux-firebase'
@@ -72,30 +73,33 @@ const enhance = compose(
7273
}))
7374
)
7475

75-
// use enhnace to pass todos list as props.todos
76-
const Todos = enhance(({ todos })) =>
77-
<div>
78-
{JSON.stringify(todos, null, 2)}
79-
</div>
80-
)
76+
function Todos({ todos }) {
77+
return (
78+
<div>
79+
{JSON.stringify(todos, null, 2)}
80+
</div>
81+
)
82+
}
8183

8284
export default enhance(Todos)
8385
```
8486

8587
_Data that depends on props_
8688

8789
```javascript
90+
import React from 'react'
8891
import { compose } from 'redux'
8992
import { connect } from 'react-redux'
90-
import { firebaseConnect, getVal } from 'react-redux-firebase'
93+
import { get } from 'lodash'
94+
import { firebaseConnect } from 'react-redux-firebase'
9195

9296
const enhance = compose(
9397
firebaseConnect((props) => ([
9498
`posts/${props.postId}` // sync /posts/postId from firebase into redux
9599
])),
96100
connect((state, props) => ({
97-
post: getVal(state.firebase.data, `posts/${props.postId}`),
98-
}))
101+
post: get(state.firebase.data, `posts.${props.postId}`),
102+
})
99103
)
100104

101105
function Post({ post }) {

docs/api/helpers.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ _Base Paths_
4545
```javascript
4646
import { connect } from 'react-redux'
4747
import { firebaseConnect, getVal } from 'react-redux-firebase'
48-
// easily replace pathToJS with getVal
4948

5049
export default connect(({ firebase }) => ({
5150
// this.props.auth loaded from state.firebase.auth
@@ -156,7 +155,7 @@ const enhance = compose(
156155
}))
157156
)
158157

159-
const Todos = ({ todos }) => {
158+
function Todos({ todos }) {
160159
// Message for if todos are loading
161160
if(!isLoaded(todos)) {
162161
return <span>Loading...</span>

docs/api/withFirebase.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,26 @@ actions.
5353
_Basic_
5454

5555
```javascript
56+
import React from 'react'
5657
import { withFirebase } from 'react-redux-firebase'
5758

58-
function AddData({ firebase: { push } }) {
59+
function AddTodo({ firebase: { push } }) {
5960
return (
6061
<div>
6162
<button onClick={() => push('todos', { done: false, text: 'Sample' })}>
6263
Add Sample Todo
6364
</button>
6465
</div>
65-
)
66+
)
6667
}
6768

68-
export default withFirebase(AddData)
69+
export default withFirebase(AddTodo)
6970
```
7071

7172
_Within HOC Composition_
7273

7374
```javascript
75+
import React from 'react'
7476
import { compose } from 'redux' // can also come from recompose
7577
import { withHandlers } from 'recompose'
7678
import { withFirebase } from 'react-redux-firebase'

docs/api/withFirestore.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ _Basic_
5353
import React from 'react'
5454
import { withFirestore } from 'react-redux-firebase'
5555

56-
function AddData({ firebase: { add } }) {
56+
function AddTodo({ firestore: { add } }) {
5757
return (
5858
<div>
5959
<button onClick={() => add('todos', { done: false, text: 'Sample' })}>

0 commit comments

Comments
 (0)