Skip to content

Instantly share code, notes, and snippets.

View trooperandz's full-sized avatar

Matt Holland trooperandz

View GitHub Profile
@trooperandz
trooperandz / rn-addons.js
Created November 14, 2021 22:14
React Native Storybook rn-addons
import '@storybook/addon-ondevice-actions/register';
import '@storybook/addon-ondevice-knobs/register';
@trooperandz
trooperandz / addons.js
Created November 14, 2021 22:14
React Native Storybook addons
import '@storybook/addon-actions/register';
import '@storybook/addon-knobs/register';
import '@storybook/addon-links/register';
@trooperandz
trooperandz / tsconfig.json
Created April 24, 2021 18:35
Alias path and module resolution TypeScript setup
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": ["src/*", "src/features/*"]
}
}
}
@trooperandz
trooperandz / babel.config.js
Last active July 6, 2023 05:00
Alias path and module resolution babel setup
module.exports = {
presets: ['@babel/preset-react', 'jest'],
plugins: [
[
'module-resolver',
{
root: ['./src'],
extensions: ['.js', '.jsx', '.json', '.svg', '.png'],
// Note: you do not need to provide aliases for same-name paths immediately under /src/
alias: {
@trooperandz
trooperandz / jest.config.js
Created January 2, 2021 00:52
React Native SVG Jest configuration
// Jest mock configuration for SVG imports
module.exports = {
moduleNameMapper: {
"\\.svg": "<rootDir>/__mocks__/svgMock.js"
}
};
@trooperandz
trooperandz / svgMock.js
Created January 2, 2021 00:48
React Native SVG mock setup
/**
* SVG setup to mock react components transformed into images from SVGs
* Place this file in your project's root __mocks__ directory.
* https://github.com/kristerkari/react-native-svg-transformer#usage-with-jest
*/
module.exports = 'SvgMock'
module.exports.ReactComponent = 'SvgMock'
@trooperandz
trooperandz / index.jsx
Created October 18, 2020 23:30
React Native svg usage example
import React from 'react';
import { View } from 'react-native';
import MyIcon from 'src/assets/my-svg-icon.svg';
export default ExampleIcon = () => (
<View>
<MyIcon width={48} height={48} fill="#000" />
</View>
);
@trooperandz
trooperandz / metro-config.js
Created October 18, 2020 23:00
React Native SVG Configuration
/**
* Metro configuration for React Native with svg support
* https://github.com/facebook/react-native
*
* @format
*/
const { getDefaultConfig } = require('metro-config');
module.exports = (async () => {
@trooperandz
trooperandz / App.jsx
Last active April 22, 2020 05:45
React Native main app entry file with redux store
import 'react-native-gesture-handler';
import React from 'react';
import { Provider } from 'react-redux';
import { Navigation as NavigationContainer } from '../navigation';
import { configureStore } from 'redux/store';
const store = configureStore();
const App = () => (
@trooperandz
trooperandz / store.js
Created April 22, 2020 05:30
React store index file
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { rootReducer } from 'redux/reducers';
export const configureStore = () => {
const store = createStore(rootReducer, applyMiddleware(thunk));
return store;
};