Skip to content

Instantly share code, notes, and snippets.

View manoj-nama's full-sized avatar
🥃
Isolating

Manoj Nama manoj-nama

🥃
Isolating
View GitHub Profile
@manoj-nama
manoj-nama / middlewares.js
Created April 4, 2019 06:22
Redux - Middlewares
import { createStore, applyMiddleware } from 'redux';
const reducer = (state = {}, action) => {
switch (action.type) {
case 'ACTION_1': {
return state;
}
case 'ACTION_2': {
return state;
}
@manoj-nama
manoj-nama / combineReducers.js
Created April 3, 2019 06:34
Redux - Combine Reducers
import { createStore, combineReducers } from 'redux';
const cartState = {
products: [],
amount: 0
}
const cart = (state = cartState, action) => {
switch (action.type) {
case 'ADD_TO_CART': {
const products = [...state.products, action.product];
@manoj-nama
manoj-nama / redux-intro.js
Created April 2, 2019 06:51
Redux - Introduction
// install redux from npm `npm install redux --save`
import { createStore } from 'redux';
const initialState = {
counter: 0
}
const reducer = (state = initialState, action) => {
switch (action.type) {
case 'INC': {
const counter = state.counter + action.data
@manoj-nama
manoj-nama / redux-middleware.js
Created January 9, 2019 12:39
Redux Bootcamp: Middlewares and Async actions example
import { createStore, combineReducers, applyMiddleware } from 'redux';
const initialState = {
loading: false,
list: []
};
const userReducer = (state = initialState, action) => {
switch(action.type) {
case 'ADD_USER': {
const list = [...state.list];
@manoj-nama
manoj-nama / cart_data.js
Created October 29, 2018 07:18
Shopping Cart - Bootcamp data
const products = [
{
"id": "91c9f4a3-18e9-4263-8cd6-c649dabd7e51",
"name": "Sauce - Hoisin",
"quantity": 35,
"image": "https://picsum.photos/200/200/?image=18",
"price": 239
},
{
"id": "837d97f1-daa4-4cf3-a933-ef4de0a367f7",
@manoj-nama
manoj-nama / App.js
Created December 13, 2017 09:38
Expo Push Notifications for React Native
import React from 'react';
import {
View,
Button,
Text,
Image,
AsyncStorage
} from 'react-native';
import { StorageKeys } from './config/constants';
import { Permissions, Notifications, Constants } from 'expo';
@manoj-nama
manoj-nama / App.js
Created December 8, 2017 11:29
React Navigation Demo
import React from 'react';
import RootNavigator from './src/Navigator';
export default class App extends React.Component {
render() {
return <RootNavigator />
}
}
@manoj-nama
manoj-nama / App.js
Created December 6, 2017 06:41
Fetch API & Networking Demo
import React from 'react';
import {
StyleSheet, Text, View, ScrollView, Platform,
FlatList,
Button,
Dimensions,
ActivityIndicator
} from 'react-native';
// import Button from './src/Button';
@manoj-nama
manoj-nama / App.js
Last active October 10, 2024 06:43
Linkedin Authentication using webview with Expo
//1. https://www.linkedin.com/developer/apps - create you app here
//2. The OAuth2.0 redirect_uri can be any web url, this needs to be the same there as well as below
//This codebase simply fetches you the token, with which you can further get user details from. This is NOT an app fetching the user details.
// There is also no error handling, failure redirect etc, you can implement that easily as we have done the success part below.
// The below code uses the module `querystring`(`yarn add querystring`) to parse the querystring, you can use anything else you would like
import React from 'react';
import { StyleSheet, Text, View, WebView } from 'react-native';
@manoj-nama
manoj-nama / index.js
Created October 13, 2017 05:48
Redux - Day 2
import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunkMiddleware from 'redux-thunk';
const usersInitialState = {
loading: false,
counter: 0,
list: []
}
const userReducer = (state = usersInitialState, action) => {
switch (action.type) {