Skip to content

Commit 24cb0a8

Browse files
committed
fix(docs): utils no longer require newer node or babel-node
* fix(docs): make examples of HOCs more consistent * fix(examples): update react-native example to use expo * fix(examples): update example deps
1 parent 6460f19 commit 24cb0a8

File tree

131 files changed

+8453
-7942
lines changed

Some content is hidden

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

131 files changed

+8453
-7942
lines changed

bin/api-docs-generate.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,17 @@ function generateDocForFile(file) {
6060
})
6161
}
6262

63-
;(async function() {
63+
;(function() {
6464
console.log(
6565
'Generating API documentation (docs/api) from JSDoc comments within src...\n'
6666
)
67-
try {
68-
await Promise.all(files.map(generateDocForFile))
69-
console.log('\nAPI documentation generated successfully!')
70-
process.exit(0)
71-
} catch (err) {
72-
console.log('Error generating API documentation: ', err.message || err)
73-
process.exit(1)
74-
}
67+
Promise.all(files.map(generateDocForFile))
68+
.then(() => {
69+
console.log('\nAPI documentation generated successfully!')
70+
process.exit(0)
71+
})
72+
.catch(err => {
73+
console.log('Error generating API documentation: ', err.message || err)
74+
process.exit(1)
75+
})
7576
})()

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/connect.md

Lines changed: 20 additions & 14 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,37 +73,42 @@ 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}`),
101+
post: get(state.firebase.data, `posts.${props.postId}`),
98102
})
99103
)
100104

101-
const Post = ({ post }) => (
102-
<div>
103-
{JSON.stringify(post, null, 2)}
104-
</div>
105-
)
105+
function Post({ post }) {
106+
return (
107+
<div>
108+
{JSON.stringify(post, null, 2)}
109+
</div>
110+
)
111+
}
106112

107113
export default enhance(Post)
108114
```

docs/api/firestoreConnect.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ import { firestoreConnect } from 'react-redux-firebase'
6666

6767
// pass todos list from redux as props.todosList
6868
export default compose(
69-
firestoreConnect(() => ['todos']), // sync todos collection from Firestore into redux
69+
firestoreConnect(['todos']), // sync todos collection from Firestore into redux
7070
connect((state) => ({
71-
todosList: state.firestore.data.todos
71+
todosList: state.firestore.data.todos,
72+
profile: state.firestore.profile, // pass profile data as props.profile
73+
auth: state.firestore.auth // pass auth data as props.auth
7274
})
7375
)(SomeComponent)
7476
```

docs/api/helpers.md

Lines changed: 2 additions & 3 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
@@ -106,7 +105,7 @@ const enhance = compose(
106105
}))
107106
)
108107

109-
const Todos = ({ todos }) => {
108+
function Todos({ todos }) {
110109
// Message for if todos are loading
111110
if(!isLoaded(todos)) {
112111
return <span>Loading...</span>
@@ -155,7 +154,7 @@ const enhance = compose(
155154
}))
156155
)
157156

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

docs/api/withFirebase.md

Lines changed: 7 additions & 7 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'
@@ -85,8 +87,8 @@ function AddTodo({ addTodo }) {
8587
)
8688
}
8789

88-
const enhance = compose(
89-
withFirebase,
90+
export default compose(
91+
withFirebase(AddTodo),
9092
withHandlers({
9193
addTodo: props => () =>
9294
props.firestore.add(
@@ -95,8 +97,6 @@ const enhance = compose(
9597
)
9698
})
9799
)
98-
99-
export default enhance(AddTodo)
100100
```
101101

102102
Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Which accepts a component to wrap and returns the

docs/api/withFirestore.md

Lines changed: 6 additions & 5 deletions
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' })}>
@@ -87,10 +87,11 @@ function AddTodo({ addTodo }) {
8787
const enhance = compose(
8888
withFirestore,
8989
withHandlers({
90-
addTodo: props => () => {
91-
const newTodo = { done: false, text: 'Sample' }
92-
return props.firestore.add({ collection: 'todos' }, newTodo)
93-
}
90+
addTodo: props => () =>
91+
props.firestore.add(
92+
{ collection: 'todos' },
93+
{ done: false, text: 'Sample' }
94+
)
9495
})
9596
)
9697

docs/integrations/react-native.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Setup and use `react-redux-firebase` as normal (described in the [use section of
1313
[react-native complete example app](https://github.com/prescottprue/react-redux-firebase/tree/master/examples/complete/react-native)
1414

1515
**NOTES**
16-
16+
* The web SDK is actually used directly, so this method is as close as it comes to web dev
17+
* Slighly less performant than using native modules since the render thread is used for all JS
1718
* Only works for versions `v2.0.0` and higher. For older versions please view the docs associated with previous version.
18-
* Will not perform as well as using native modules since the render thread is used for all JS
1919

2020
## Native Modules
2121

0 commit comments

Comments
 (0)