Skip to content

Instantly share code, notes, and snippets.

View xiongemi's full-sized avatar
🏠
Working from home

Emily Xiong xiongemi

🏠
Working from home
View GitHub Profile
@xiongemi
xiongemi / navigation.tsx
Created March 22, 2022 05:36
mock NavigationDecorator with route param id passed in
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import React from 'react';
const NavigationDecorator = (story) => {
const Stack = createNativeStackNavigator();
return (
<NavigationContainer independent={true}>
<Stack.Navigator>
<Stack.Screen
@xiongemi
xiongemi / film-list-item.stories.tsx
Last active April 4, 2022 05:02
story of react native component that uses NavigationDecorator
import { storiesOf } from '@storybook/react-native';
import { mockFilmEntity } from '@studio-ghibli-search-engine/models';
import React from 'react';
import { NavigationDecorator } from '../../../storybook/mocks/navigation';
import FilmListItem from './film-list-item';
storiesOf('FilmListItem', module)
.addDecorator(NavigationDecorator)
// src/storybook/mocks/navigation.tsx
import { NavigationContainer } from '@react-navigation/native';
import React from 'react';
export const NavigationDecorator = (story) => {
return (
<NavigationContainer independent={true}>{story()}</NavigationContainer>
);
};
// at apps/poetry-app/src/components/poem-of-the-day/poem-of-the-day.tsx
import { PoemResponse, poetryService } from '@nx-expo-poetry/services';
import React, { useEffect, useState } from 'react';
import {
Card,
Title,
Paragraph,
Subheading,
ActivityIndicator,
} from 'react-native-paper';
// at libs/services/src/models/poem-response.interface.ts
export interface PoemResponse {
title: string;
author: string;
lines: string[];
linecount: string;
}
@xiongemi
xiongemi / App.tsx
Last active February 14, 2022 01:40
poem of the day component expo
import React from 'react';
import { SafeAreaView, ScrollView } from 'react-native';
import { Provider as PaperProvider } from 'react-native-paper';
import PoemOfTheDay from '../components/poem-of-the-day/poem-of-the-day';
const App = () => {
return (
<PaperProvider>
<SafeAreaView>
@xiongemi
xiongemi / film.props.ts
Created January 7, 2022 18:16
film react native component
import { AnyAction, ThunkDispatch } from '@reduxjs/toolkit';
import {
filmsActions,
filmsSelectors,
RootState,
} from '@studio-ghibli-search-engine/store';
const mapStateToProps = (state: RootState) => {
return {
getFilm: (id: string) => filmsSelectors.selectFilmById(id)(state),
@xiongemi
xiongemi / app.tsx
Created October 9, 2021 04:40
daily-horoscope-web
import { rootStore } from '@aztro-daily-horoscope/store';
import {
ZodiacSignListContainer,
HoroscopeCardContainer,
} from '@aztro-daily-horoscope/ui';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import * as React from 'react';
import { Provider } from 'react-redux';
@xiongemi
xiongemi / horoscope.slice.ts
Created October 9, 2021 04:32
daily-horoscope-app horoscope.slice.ts
import {
AdhHoroscope,
AdhHoroscopeDay,
AdhZodiacSign,
AdhZodiacSignItem,
} from '@aztro-daily-horoscope/models';
import {
aztroService,
transfromAztroHoroscpeResponseToAdhHoroscope,
} from '@aztro-daily-horoscope/services';
@xiongemi
xiongemi / horoscope.slice.ts
Created October 9, 2021 04:26
daily-horoscope-app horoscope.slice.ts horoscopeSelectors
const getHoroscopeState = (rootState: RootState): HoroscopeState =>
rootState[HOROSCOPE_FEATURE_KEY];
const getUserZodiacItem = (
rootState: RootState
): AdhZodiacSignItem | undefined => getHoroscopeState(rootState).zodiacSignItem;
const getUserZodiac = (
rootState: RootState
): AdhZodiacSign | undefined => getUserZodiacItem(rootState)?.zodiacSign;