Skip to content

Instantly share code, notes, and snippets.

View bharat-tiwari's full-sized avatar

Bharat Tiwari bharat-tiwari

View GitHub Profile
import React from 'react';
type compProps = {
title: string;
}
const Home = (props: compProps) => {
const { title } = props;
return (
<div>
@bharat-tiwari
bharat-tiwari / index.js
Last active June 11, 2021 06:13
index.js importing gitlab package
import { orgThemes } from '@btiwari-gitlab/app-themes';
const applyTheme = theme => {
const body = document.querySelector('body');
const info = document.querySelector('#info');
body.style.background = orgThemes[theme].background;
body.style.color = orgThemes[theme].text;
info.innerText = theme.toUpperCase();
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Use NPM package registry from Gitlab </title>
</head>
<body>
@bharat-tiwari
bharat-tiwari / .eslintignore
Last active June 4, 2021 06:33
.eslintignore
# don't lint:
node_modules
# don't lint build output
dist
build
lib
# don't lint unit-test coverage
coverage
@bharat-tiwari
bharat-tiwari / App.tsx
Created December 22, 2020 05:34
App component with NativeBase header
import React from 'react';
import { Button, Container, Header, Title, Content, Icon, Left, Right, Text, Body } from "native-base";
import { React$Node } from './../TypesAndInterfaces/AppTypes';
/**
* @name App
* @description App Component function
*/
const App: () => React$Node = () => {
@bharat-tiwari
bharat-tiwari / RN-Android-UpgradeGradleVersion.md
Created July 12, 2020 17:10
React Native - Android - Upgrade the gradle version

Version compatibility between GPP, the React-Native Android project's gradle version and Android tools

GPP's most recent version as of the writing of this post is GPP 2.8.0. This version requires Gradle version ≥ 6 and Android tools build gradle version in our app ≥ 4.0.

Upgrade the gradle version

On your terminal, cd to the app's project folder, then run below commands to upgrade the gradle version of the app's android project. The latest gradle version as of writing of this post is 6.5👇

cd android
@bharat-tiwari
bharat-tiwari / build.gradle
Last active June 15, 2020 13:15
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
@bharat-tiwari
bharat-tiwari / Header.spec.tsx
Created November 22, 2019 14:30
Unit tests for Header component
import React from 'react';
import Header from './header';
import renderer from 'react-test-renderer';
describe('Header', () => {
it('should render correctly', () => {
const header = renderer.create(<Header title="Test" />).toJSON;
expect(header).toMatchSnapshot();
});
});
@bharat-tiwari
bharat-tiwari / Header.tsx
Created November 22, 2019 14:22
Header component
import * as React from 'react';
import {StyleSheet, View, Text} from 'react-native';
interface CompProps {
title: string;
}
const Header = (props: CompProps) => {
return (
<View style={styles.container}>
@bharat-tiwari
bharat-tiwari / jest.config.js
Created November 18, 2019 18:09
jest config for RN Typescript tests
module.exports = {
preset: 'react-native',
testRegex: '(/__tests__/.*|/src/.*\\.(test|spec))\\.(jsx?|tsx?)$',
moduleFileExtensions: [
'ts',
'tsx',
'js',
'jsx',
'json',
'ios.ts',