Skip to content

Commit

Permalink
v3.0.0-alpha.14
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
prescottprue committed Jul 31, 2019
1 parent 068ad3f commit 9612d40
Show file tree
Hide file tree
Showing 170 changed files with 42,937 additions and 30,122 deletions.
24 changes: 0 additions & 24 deletions .eslintrc

This file was deleted.

35 changes: 35 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = {
root: true,

parser: 'babel-eslint',

extends: ['standard', 'standard-react', 'prettier', 'prettier/react'],
plugins: ['babel', 'react', 'prettier'],

settings: {
react: {
version: 'detect'
}
},

env: {
browser: true,
es6: true
},

rules: {
semi: [2, 'never'],
'no-console': 'error',
'prettier/prettier': ['error', {
singleQuote: true,
trailingComma: 'none',
semi: false,
bracketSpacing: true,
jsxBracketSameLine: true,
printWidth: 80,
tabWidth: 2,
useTabs: false
}]
}
};

22 changes: 2 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ We welcome any type of contribution, not only code. You can help with
- **Marketing**: writing blog posts, howto's, printing stickers, ...
- **Community**: presenting the project at meetups, organizing a dedicated meetup for the local community, ...
- **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.
- **Money**: we welcome financial contributions in full transparency on our [open collective](https://opencollective.com/react-redux-firebase).
- **Money**: we welcome financial contributions as detailed in the [financial contributions section](#financial-contributions).

## Your First Contribution

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

## Financial contributions

We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/react-redux-firebase).
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.
Financial contributions are welcomed through either [patreon](https://www.patreon.com/prescottprue) or [open collective](https://opencollective.com/react-redux-firebase).

## Questions

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

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


### Sponsors

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))

<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>

<!-- This `CONTRIBUTING.md` is based on @nayafia's template https://github.com/nayafia/contributing-template -->
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ The [Material Example](https://github.com/prescottprue/react-redux-firebase/tree

## Features

- Out of the box support for authentication (with auto load user profile)
- Full Firebase Platform Support Including Real Time Database, Firestore, and Storage
- Automatic binding/unbinding of listeners through React Higher Order Components (`firebaseConnect` and `firestoreConnect`)
- [Population capability](http://react-redux-firebase.com/docs/populate) (similar to mongoose's `populate` or SQL's `JOIN`)
- Support small data ( using `value` ) or large datasets ( using `child_added`, `child_removed`, `child_changed` )
- Multiple queries types supported including `orderByChild`, `orderByKey`, `orderByValue`, `orderByPriority`, `limitToLast`, `limitToFirst`, `startAt`, `endAt`, `equalTo`
- Tons of examples of integrations including [`redux-thunk`](https://github.com/gaearon/redux-thunk) and [`redux-observable`](https://redux-observable.js.org/)
- Server Side Rendering Support
- [`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)
* Out of the box support for authentication (with auto load user profile)
* Full Firebase Platform Support Including Real Time Database, Firestore, and Storage
* Automatic binding/unbinding of listeners through React Higher Order Components (`firebaseConnect` and `firestoreConnect`)
* [Population capability](http://react-redux-firebase.com/docs/populate) (similar to mongoose's `populate` or SQL's `JOIN`)
* Support small data ( using `value` ) or large datasets ( using `child_added`, `child_removed`, `child_changed` )
* Multiple queries types supported including `orderByChild`, `orderByKey`, `orderByValue`, `orderByPriority`, `limitToLast`, `limitToFirst`, `startAt`, `endAt`, `equalTo`
* Tons of examples of integrations including [`redux-thunk`](https://github.com/gaearon/redux-thunk) and [`redux-observable`](https://redux-observable.js.org/)
* Server Side Rendering Support
* [`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)

## Installation

Expand Down Expand Up @@ -64,7 +64,7 @@ const fbConfig = {}

// react-redux-firebase config
const rrfConfig = {
userProfile: 'users',
userProfile: 'users'
// useFirestoreForProfile: true // Firestore for Profile instead of Realtime DB
}

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

// Add firebase to reducers
const rootReducer = combineReducers({
firebase: firebaseReducer,
firebase: firebaseReducer
// firestore: firestoreReducer // <- needed if using firestore
})

Expand All @@ -103,7 +103,7 @@ function App() {
);
}

render(<App/>, document.getElementById('root'));
render(<App />, document.getElementById('root'))
```

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

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


**Load Data On Click**

```jsx
Expand Down Expand Up @@ -294,6 +293,7 @@ If you plan to use Firestore, you should checkout [`redux-firestore`][redux-fire
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.

## [Docs](http://react-redux-firebase.com)

See full documentation at [react-redux-firebase.com](http://react-redux-firebase.com)

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

### Real World Applications

* [fireadmin.io](http://fireadmin.io) - Firebase Instance Management Tool (source [available here](https://github.com/prescottprue/fireadmin))

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

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

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/).
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/).

## Discussion

Expand Down
23 changes: 12 additions & 11 deletions bin/api-docs-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ function uploadList(files) {
)
}

;(async function() {
try {
await runCommand('gsutil') // check for existence of gsutil
await uploadList(first)
await uploadList(second)
console.log('Docs uploaded successfully') // eslint-disable-line no-console
process.exit(0)
} catch (err) {
console.log('Error uploading docs:', err.message) // eslint-disable-line no-console
process.exit(1)
}
;(function() {
runCommand('gsutil') // check for existence of gsutil
.then(() => uploadList(first))
.then(() => uploadList(second))
.then(() => {
console.log('Docs uploaded successfully') // eslint-disable-line no-console
process.exit(0)
})
.catch(err => {
console.log('Error uploading docs:', err.message) // eslint-disable-line no-console
process.exit(1)
})
})()
4 changes: 3 additions & 1 deletion docs/api/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ Default configuration options

- `userProfile` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** `null` Location on Firebase where user
profiles are stored. Often set to `'users'`.
- `profileFactory` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** `null` Function for changing how profile is written
to database (both RTDB and Firestore).
- `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
online users is stored. Often set to `'presence'` or `'onlineUsers'`. If a function
is passed, the arguments are: `(currentUser, firebase)`.
Expand Down Expand Up @@ -144,7 +146,7 @@ Default configuration options
state (name given when passing reducer to combineReducers). Used in
firebaseAuthIsReady promise (see
[#264](https://github.com/prescottprue/react-redux-firebase/issues/264)).
- `attachAuthIsReady` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` Whether or not to attach
- `attachAuthIsReady` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `false` Whether or not to attach
firebaseAuthIsReady to store. authIsLoaded can be imported and used
directly instead based on preference.
- `firestoreNamespace` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `firestoreHelpers` Namespace for
Expand Down
24 changes: 14 additions & 10 deletions docs/api/firebaseConnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ needing to access a firebase instance created under a different store key.
_Basic_

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

```javascript
import React from 'react'
import { compose } from 'redux'
import { connect } from 'react-redux'
import { firebaseConnect } from 'react-redux-firebase'
Expand All @@ -72,30 +73,33 @@ const enhance = compose(
}))
)

// use enhnace to pass todos list as props.todos
const Todos = enhance(({ todos })) =>
<div>
{JSON.stringify(todos, null, 2)}
</div>
)
function Todos({ todos }) {
return (
<div>
{JSON.stringify(todos, null, 2)}
</div>
)
}

export default enhance(Todos)
```

_Data that depends on props_

```javascript
import React from 'react'
import { compose } from 'redux'
import { connect } from 'react-redux'
import { firebaseConnect, getVal } from 'react-redux-firebase'
import { get } from 'lodash'
import { firebaseConnect } from 'react-redux-firebase'

const enhance = compose(
firebaseConnect((props) => ([
`posts/${props.postId}` // sync /posts/postId from firebase into redux
])),
connect((state, props) => ({
post: getVal(state.firebase.data, `posts/${props.postId}`),
}))
post: get(state.firebase.data, `posts.${props.postId}`),
})
)

function Post({ post }) {
Expand Down
3 changes: 1 addition & 2 deletions docs/api/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ _Base Paths_
```javascript
import { connect } from 'react-redux'
import { firebaseConnect, getVal } from 'react-redux-firebase'
// easily replace pathToJS with getVal

export default connect(({ firebase }) => ({
// this.props.auth loaded from state.firebase.auth
Expand Down Expand Up @@ -156,7 +155,7 @@ const enhance = compose(
}))
)

const Todos = ({ todos }) => {
function Todos({ todos }) {
// Message for if todos are loading
if(!isLoaded(todos)) {
return <span>Loading...</span>
Expand Down
8 changes: 5 additions & 3 deletions docs/api/withFirebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,26 @@ actions.
_Basic_

```javascript
import React from 'react'
import { withFirebase } from 'react-redux-firebase'

function AddData({ firebase: { push } }) {
function AddTodo({ firebase: { push } }) {
return (
<div>
<button onClick={() => push('todos', { done: false, text: 'Sample' })}>
Add Sample Todo
</button>
</div>
)
)
}

export default withFirebase(AddData)
export default withFirebase(AddTodo)
```

_Within HOC Composition_

```javascript
import React from 'react'
import { compose } from 'redux' // can also come from recompose
import { withHandlers } from 'recompose'
import { withFirebase } from 'react-redux-firebase'
Expand Down
2 changes: 1 addition & 1 deletion docs/api/withFirestore.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ _Basic_
import React from 'react'
import { withFirestore } from 'react-redux-firebase'

function AddData({ firebase: { add } }) {
function AddTodo({ firestore: { add } }) {
return (
<div>
<button onClick={() => add('todos', { done: false, text: 'Sample' })}>
Expand Down

0 comments on commit 9612d40

Please sign in to comment.