Skip to content

Instantly share code, notes, and snippets.

View CryceTruly's full-sized avatar
🎯
Focusing

cryce truly CryceTruly

🎯
Focusing
View GitHub Profile
export default [
{
text: "Afghanistan (+93)",
value: "+93",
flag: "af",
key: "af",
},
{
text: "Aland Islands",
value: "",
{
"AED": "United Arab Emirates Dirham",
"AFN": "Afghan Afghani",
"ALL": "Albanian Lek",
"AMD": "Armenian Dram",
"ANG": "Netherlands Antillean Guilder",
"AOA": "Angolan Kwanza",
"ARS": "Argentine Peso",
"AUD": "Australian Dollar",
"AWG": "Aruban Florin",
import AsyncStorage from '@react-native-async-storage/async-storage';
import axios, {AxiosError} from 'axios';
import {logOutUserLocal} from 'redux/actions/auth/logout/clearAllUser';
import store from 'redux/store';
import envs from 'config/env';
// Getting token from local Storage
async function getLocalToken() {
const token = await AsyncStorage.getItem('token');
return `Bearer ${token}`;
Here is how you can do it when the items in the arrays are objects.
The idea is to find the array of only the keys in an inner array using the map function
Then foreach of those check if they contain a spectific element key in the outer array.
const existsInBothArrays = array1.filter((element1) =>
array2.map((element2) => element2._searchKey).includes(element1._searchKey),
);
import AsyncStorage from '@react-native-async-storage/async-storage';
import axios from 'axios';
import envs from '../config/env';
import {LOGOUT} from '../constants/routeNames';
import * as RootNavigation from '../navigations/RootNavigation';
let headers = {};
const axiosInstance = axios.create({
baseURL: envs.BACKEND_URL,
@CryceTruly
CryceTruly / useRef.js
Created December 16, 2020 05:08
Implementing componentDidUpdate using hooks.
const initialItemsRef = useRef([]);
useEffect(() => {
if (userItems.length) {
const prev = initialItemsRef.current;
initialWalletsRef.current = <whatToCheckForChanges>;
const newones = initialItemsRef.current;
if (newones.length - prev.length === 1) {
const difference = newones.find((x) => !prev.map((i) => i.AccountNumber).includes(x.AccountNumber));
import "./App.css";
import { useState } from "react";
function App() {
const options = [
{
header: {
name: "Account",
},
@CryceTruly
CryceTruly / autoheight.js
Created November 1, 2020 19:22
react input component with dynamic height
import React, { useState } from "react";
import "./style.css";
const DynamicHeightInput = () => {
const [textareaHeight, setTextareaHeight] = useState(42);
const [formValue, setFormValue] = useState({});
const onChange = (event) => {
event.preventDefault();
event.persist();
import React, { useState } from "react";
import "./App.css";
function App() {
const [form, setForm] = useState([]);
const [submitted, setFormSubmitted] = useState(false);
const someEmpty = form.some(
(item) => item.Platform === "" || item.Username === ""
);
from rest_framework.views import exception_handler
from rest_framework import status
from django.http import Http404
def custom_exception_handler(exc, context):
"""
This function will handle errors that are returned by
the different views.
The `handlers` dictionary will map