This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "./App.css"; | |
import { useState } from "react"; | |
function App() { | |
const options = [ | |
{ | |
header: { | |
name: "Account", | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
import "./App.css"; | |
function App() { | |
const [form, setForm] = useState([]); | |
const prevIsValid = () => { | |
if (form.length === 0) { | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import JsonResponse | |
def error_404(request, exception): | |
message = ("The endpoint you are trying to access might " | |
"have been removed, " | |
"had its name changed, or is temporarily unavailable. " | |
"Please check the documentation here : " | |
"/ docs and try again later.") | |
response = JsonResponse(data={"message": message, 'status_code': 404}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 === "" | |
); |