This project was bootstrapped with Create React Native App. My code is mainly in the app/
directory.
Make sure you have npm
installed on your computer. For this project, I'm using npm@4.6.1
and node@v8.9.4
.
-
Install dependencies:
npm i
-
Start the app on iOS simulator:
npm run ios
This issue is present when trying to start the simulator for the first time. If encountered, please re-run the command and it should work correctly.
I'm using jest
& enzyme
to write the test cases.
To run the tests:
npm test
The data used to generate display components lives in redux
state. The state has the following structure:
{
contentReducers: {
currentPostId: int, // monotonically increasing
currentCommentId: int, // monotonically increasing
posts: {
<id>: {
children: [ids of children],
content: string,
downvoteCount: int,
upvoteCount: int,
title: string,
id: int
},
...
},
comments: {
<id>: {
children: [ids of children],
content: string,
downvoteCount: int,
upvoteCount: int,
id: int
},
...
}
},
nav: navReducer // managed by react-navigation-redux-helpers package
}
Posts/comments are stored in dictionary form instead of array to allow O(1) lookup, given the id.