This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const generateCalendar = (today: Date) => { | |
const daysInMonth = getDaysInMonth(today) | |
const firstDay = new Date(today.getFullYear(), today.getMonth()).getDay() | |
// in order to calculate how many calendar weeks there are (starting on Sunday), we can take | |
// days in the month and add first day + 1 to include the first week offset. returns an array | |
// that looks something like this: | |
// [undefined, undefined, undefined, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] | |
const daysWithOffset = new Array(daysInMonth + firstDay).fill(undefined).map((v, i) => { | |
if (i < firstDay) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"data": { | |
"metrics": [ | |
{ | |
"time": 1577905826702, | |
"value": 62 | |
}, | |
{ | |
"time": 1577905886702, | |
"value": 62 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import {SafeAreaView, View, Text} from 'react-native' | |
import Amplify from 'aws-amplify' | |
import awsconfig from './aws-exports' | |
import {withAuthenticator} from 'aws-amplify-react-native' | |
Amplify.configure(awsconfig) | |
const App = props => { | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import {SafeAreaView, View, Text} from 'react-native' | |
const App = props => { | |
return ( | |
<SafeAreaView> | |
<View> | |
<Text>Home screen!</Text> | |
</View> | |
</SafeAreaView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { Context } from '../lib/context' | |
import { firebase, db } from '../lib/firebase' | |
import Data from '../components/Data' | |
export default class Home extends React.Component { | |
constructor (props) { | |
super(props) | |
this.state = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
/** | |
* The goal of this component is to wrap another component and give it some data from the | |
* database while maintaining state and bindings and significantly cutting down on | |
* boilerplate. | |
* | |
* This component expects a function | |
* See [this article](https://medium.com/merrickchristensen/function-as-child-components-5f3920a9ace9) | |
* for more information on why function-as-child components are awesome for this use case |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { Context } from '../lib/context' | |
import { firebase } from '../lib/firebase' | |
export default class Home extends React.Component { | |
constructor (props) { | |
super(props) | |
this.state = { | |
email: '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
import AuthBindings from '../components/AuthBindings | |
... | |
<> | |
<AuthBindings firebase={firebase} store={store} /> | |
<Component store={store} {...pageProps} /> | |
</> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
/** | |
* A component that is used to bind the current user the store using Firebase | |
* | |
* @param {function} store.set - must receive a `store` prop that has a `set` function | |
* @param {Object} firebase - must receive an initialized `firebase` as a prop | |
* | |
* Render this alongside the top-level component of your app. Should only be rendered once. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import App, { Container } from 'next/app' | |
import { firebase } from '../lib/firebase' | |
import { Context, Provider } from '../lib/context' | |
// Use this additional container to bind firebase auth listener to store | |
class _App extends App { | |
render () { | |
const { Component, pageProps } = this.props |
NewerOlder