Skip to content

Instantly share code, notes, and snippets.

View abegehr's full-sized avatar
👨‍💻

Anton Begehr abegehr

👨‍💻
View GitHub Profile
@abegehr
abegehr / App_react-native-maps.js
Last active February 13, 2020 12:48
react-native-map-clustering-example
import React from "react";
import { StyleSheet, View } from "react-native";
import MapView, { Marker } from "react-native-maps";
const initialRegion = {
latitude: 37.72825,
longitude: -122.4324,
latitudeDelta: 0.25,
longitudeDelta: 0.15
};
@abegehr
abegehr / renderRandomMarkers.js
Created February 13, 2020 12:49
renders n random Markers
function renderRandomMarkers(n) {
const { latitude, longitude, latitudeDelta, longitudeDelta } = initialRegion;
return new Array(n).fill().map((x, i) => (
<Marker
key={i}
coordinate={{
latitude: latitude + (Math.random() - 0.5) * latitudeDelta,
longitude: longitude + (Math.random() - 0.5) * longitudeDelta
}}
/>
@abegehr
abegehr / App_react-native-map-clustering.js
Last active February 17, 2020 13:18
simple App.js with react-native-map-clustering
import React from "react";
import { StyleSheet, View } from "react-native";
import MapView from "react-native-map-clustering";
import { Marker } from "react-native-maps";
const initialRegion = {
latitude: 37.72825,
longitude: -122.4324,
latitudeDelta: 0.25,
longitudeDelta: 0.15
@abegehr
abegehr / react-navigation-horizontal-modal-stack simple_createStackNavigator.js
Last active February 25, 2020 17:01
simple react-navigation createStackNavigator() with Home, Links, and Settings screens
export default createAppContainer(
createStackNavigator(
{
Home: HomeScreen,
Links: LinksScreen,
Settings: SettingsScreen
},
{
initialRouteName: "Home",
mode: "modal",
@abegehr
abegehr / react-navigation-horizontal-modal-stack horizontal_createStackNavigator.js
Created February 25, 2020 17:02
react-navigation createStackNavigator() for horizontal modals
export default createAppContainer(
createStackNavigator(
{
Home: HomeScreen,
Links: {
screen: LinksScreen,
navigationOptions: {
gestureDirection: "horizontal",
cardStyleInterpolator: forHorizontalModal
}
@abegehr
abegehr / react-navigation-horizontal-modal-stack forHorizontalModal.js
Created February 25, 2020 17:10
CardStyleInterpolators.forHorizontalModal
export function forHorizontalModal({
current,
next,
inverted,
layouts: { screen }
}: StackCardInterpolationProps): StackCardInterpolatedStyle {
const translateFocused = multiply(
current.progress.interpolate({
inputRange: [0, 1],
outputRange: [screen.width, 0],
@abegehr
abegehr / async_await_try_catch.js
Created March 27, 2020 19:27
Promise.then().catch() vs. async, await, try, catch
async function call1() {
try {
return await promise1;
}
catch (err) {
console.warn("promise1 – Error: ", err);
}
}
async function call2() {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.