Skip to content

Commit 0916a27

Browse files
authored
Improve local dev experience (#152)
* make sample-simple depend on local reactfire instead of published version * add a Prettier formatter pre-commit hook * run prettier on the whole project * Clarify local development instructions
1 parent 3462ec5 commit 0916a27

File tree

8 files changed

+212
-33
lines changed

8 files changed

+212
-33
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ render(<App />, document.getElementById('root'));
9090

9191
### For development
9292

93-
1. `yarn install`
94-
1. `cd` into the _reactfire/reactfire_ directory. run `yarn run watch`.
95-
1. In a new terminal, `cd` into the _reactfire/sample-simple_ directory. run `yarn start`.
96-
1. Head over to https://localhost:3000 to see the running sample
93+
1. At the project root, run `yarn install`
94+
1. `cd` into the _reactfire_ directory. Run `yarn` and `yarn watch`.
95+
1. In a new terminal, `cd` into the _reactfire/sample-simple_ directory. run `yarn` and `yarn start`.
96+
1. Head over to https://localhost:3000 to see the running sample! If you edit the reactfire source, the sample will reload.
9797

9898
### Testing
9999

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,15 @@
55
"reactfire/pub/reactfire",
66
"sample-simple",
77
"sample-complex"
8-
]
8+
],
9+
"devDependencies": {
10+
"husky": "^3.0.8",
11+
"prettier": "^1.18.2",
12+
"pretty-quick": "^1.11.1"
13+
},
14+
"husky": {
15+
"hooks": {
16+
"pre-commit": "pretty-quick --staged"
17+
}
18+
}
919
}

reactfire/firestore/firestore.test.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
useFirestoreCollection,
1010
FirebaseAppProvider,
1111
useFirestoreCollectionData,
12-
useFirestoreDocData,
12+
useFirestoreDocData
1313
} from '..';
1414
import { firestore } from 'firebase/app';
1515

@@ -21,7 +21,7 @@ describe('Firestore', () => {
2121
projectId: '12345',
2222
databaseName: 'my-database',
2323
auth: { uid: 'alice' }
24-
}) as import('firebase').app.App;
24+
}) as import('firebase').app.App;
2525
// TODO(davideast): Wait for rc and analytics to get included in test app
2626
});
2727

@@ -73,7 +73,7 @@ describe('Firestore', () => {
7373
expect(getByTestId('readSuccess')).toContainHTML(mockData.a);
7474
});
7575
});
76-
76+
7777
describe('useFirestoreDocData', () => {
7878
it('can get a Firestore document [TEST REQUIRES EMULATOR]', async () => {
7979
const mockData = { a: 'hello' };
@@ -89,11 +89,7 @@ describe('Firestore', () => {
8989
const ReadFirestoreDoc = () => {
9090
const data = useFirestoreDocData<any>(ref, { idField: 'id' });
9191

92-
return (
93-
<h1 data-testid={data.id}>
94-
{data.a}
95-
</h1>
96-
);
92+
return <h1 data-testid={data.id}>{data.a}</h1>;
9793
};
9894
const { getByTestId } = render(
9995
<FirebaseAppProvider firebase={app}>
@@ -148,7 +144,7 @@ describe('Firestore', () => {
148144
expect(getAllByTestId('listItem').length).toEqual(2);
149145
});
150146
});
151-
147+
152148
// THIS TEST CAUSES A REACT `act` WARNING
153149
// IT WILL BE FIXED IN REACT 16.9
154150
// More info here: https://github.com/testing-library/react-testing-library/issues/281
@@ -188,5 +184,4 @@ describe('Firestore', () => {
188184
expect(getAllByTestId('listItem').length).toEqual(2);
189185
});
190186
});
191-
192187
});

reactfire/firestore/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { firestore } from 'firebase/app';
2-
import { doc, collectionData, fromCollectionRef, docData } from 'rxfire/firestore';
2+
import {
3+
doc,
4+
collectionData,
5+
fromCollectionRef,
6+
docData
7+
} from 'rxfire/firestore';
38
import { ReactFireOptions, useObservable } from '..';
49

510
/**

reactfire/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
"test-dev": "jest --verbose --watch",
1111
"emulator": "firebase emulators:start --only firestore",
1212
"test": "firebase emulators:exec --only firestore \"jest --no-cache --verbose --detectOpenHandles --forceExit\"",
13-
"watch": "tsc --watch",
14-
"build": "rm -rf pub && tsc && cp package.pub.json pub/reactfire/package.json && cp ../README.md pub/reactfire/README.md && cp ../LICENSE pub/reactfire/LICENSE"
13+
"copy-package-json": "cp package.pub.json pub/reactfire/package.json",
14+
"watch": "yarn build && tsc --watch",
15+
"build": "rm -rf pub && tsc && yarn copy-package-json && cp ../README.md pub/reactfire/README.md && cp ../LICENSE pub/reactfire/LICENSE"
1516
},
1617
"repository": {
1718
"type": "git",

sample-simple/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"react-dom": "^16.8.6",
1010
"react-firebaseui": "^3.1.2",
1111
"react-scripts": "3.0.1",
12-
"reactfire": "^2.0.0-alpha.2"
12+
"reactfire": "2.0.0"
1313
},
1414
"scripts": {
1515
"start": "react-scripts start",

sample-simple/src/Firestore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const List = props => {
7878
<li key={animal.id}>
7979
{animal.commonName}{' '}
8080
<button onClick={() => removeAnimal(animal.id)}>X</button>
81-
</li>
81+
</li>
8282
))}
8383
</ul>
8484
</>

0 commit comments

Comments
 (0)