React Native + Redux process in background


I have a react-native application (android) where the redux store stores user login information, among other things this application runs a background geologization process and calls an API.

In development, the background application works perfectly, the problem is when I do productive construction. After a few hours in the background, the app "quits", not directly, but when you return to the app, it stays on a blank screen and starts again as if all the redux data that would be normal is deleted if the process and reopens.

In development, this doesn't happen to me, the app can run in the background for hours.


I have tried with community libraries to turn off battery management, which doesn't limit CPU usage, as the app is still running in the background but I can't find any solution.


  "name": "VoysSender",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  "dependencies": {
    "@react-native-community/geolocation": "^2.0.2",
    "@unimodules/core": "^5.0.0",
    "axios": "^0.19.0",
    "expo": "^36.0.2",
    "expo-asset": "^8.0.0",
    "expo-constants": "^8.0.0",
    "expo-file-system": "^8.0.0",
    "expo-font": "^8.0.0",
    "expo-vector-icons": "^10.0.1",
    "geolib": "^3.2.1",
    "i": "^0.3.6",
    "npm": "^6.13.4",
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-background-timer": "^2.1.1",
    "react-native-elements": "^1.2.7",
    "react-native-fs": "^2.16.2",
    "react-native-gesture-handler": "^1.5.3",
    "react-native-keep-awake": "^4.0.0",
    "react-native-maps": "0.26.1",
    "react-native-maps-directions": "^1.7.3",
    "react-native-modalbox": "^2.0.0",
    "react-native-paper": "^3.4.0",
    "react-native-pose": "^0.9.1",
    "react-native-reanimated": "^1.4.0",
    "react-native-sketch-draw": "^2.0.2",
    "react-native-tab-view": "^2.11.0",
    "react-native-turn-off-optimization": "^1.0.3",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "^4.0.10",
    "react-navigation-animated-switch": "^0.4.1",
    "react-navigation-drawer": "^2.3.3",
    "react-navigation-material-bottom-tabs": "^2.1.5",
    "react-navigation-stack": "^1.10.3",
    "react-navigation-tabs": "^2.6.2",
    "react-redux": "^7.1.3",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0"
  "devDependencies": {
    "@babel/core": "7.7.7",
    "@babel/runtime": "7.7.7",
    "@react-native-community/eslint-config": "0.0.5",
    "babel-jest": "24.9.0",
    "eslint": "6.8.0",
    "jest": "24.9.0",
    "metro-react-native-babel-preset": "0.56.3",
    "react-test-renderer": "16.9.0"
  "jest": {
    "preset": "react-native"


react – How to transmit data from response headers to ApolloProvider with SSR?

I work with an application built with Nextjs and Apollo. I get a token in the Graphql response headers. I can read this server-side token and have to pass it to the client-side Apollo provider.

    data: {
        isLoggedIn: false

const afterwareLink = new ApolloLink((operation, forward) => {  
    return forward(operation).map(response => {
        const context = operation.getContext();
        const {
            response: { headers },
        } = context;

        if (headers) {
            const authorization = headers.get('authorization');

            if (authorization) {
                // what to do next? I need some how set isLoggedIn to true...
        return response;

const link = ApolloLink.from((
    new RetryLink(),

const client = new ApolloClient({  

function App({ children }){
    return (

I have tried to define the context inside ApolloLink:

    operation.setContext({ isLoggedIn: true });

I cannot write directly to the cache because the page is rendered on the server side.

css – Use of React, implementation of the quiz

I created a quiz app using React:

It would be great to get feedback, especially the animation that occurs when the "next" button is clicked. I realized that animation occurs first, then does not happen, then reproduces. You are wondering what I am missing for animation to happen anytime when you click Next.

I have created an "animation" status field in the Quiz component so that it goes from false to true, and vice versa.

class Quiz extends React.Component {
  state = {
    currentQuiz: 0,
    numOfQuestions: 0,
    score: 0,
    resultSummary: false,
    animation: false

  handleNextQuestion = answer => {
    const { currentQuiz, numOfQuestions, score } = this.state;

    if (answer) {
        score: score + 1,
        numOfQuestions: numOfQuestions + 1
    } else {
        numOfQuestions: numOfQuestions + 1

    if (numOfQuestions === quizzes(currentQuiz).questions.length - 1) {
        resultSummary: true

    if (!this.state.animation) {
      this.setState({ animation: "multiple-choices" });
    } else {
      this.setState({ animation: false });

  handleNextQuiz = () => {
    const { currentQuiz } = this.state;

    if (currentQuiz + 1 === quizzes.length) {
        resultSummary: false,
        numOfQuestions: 0,
        score: 0,
        currentQuiz: 0
    } else {
        resultSummary: false,
        numOfQuestions: 0,
        score: 0,
        currentQuiz: currentQuiz + 1

  render() {
    const {
    } = this.state;

    const { title, questions } = quizzes(currentQuiz);
    const currentQuestion = questions(numOfQuestions);

    const shuffledAnswerChoices = shuffle((

    return (


{resultSummary ? ( ) : ( )}
); } } export default Quiz;

You are also wondering if 1) there is a better way to manage status in this little app and / or 2) advice on media queries for mobile devices (I'm sort of new to responsive design) .

Do React (and Vue.js) frameworks support extensibility?

Please forgive me if I mix the terminology here, I don't know it at all. I wanted to find a way to support extensibility in a web application; I wanted a web application similar to Microsoft Azure DevOps, where the ready-to-use web application is fully functional, but also expandable in a controlled manner with contribution points.

I explored the Angular, React and Vue.js options as a front end framework for the web application. At first, I was going to try to simulate how Microsoft Azure DevOps handles extensions using a mixture of iframe and XDM (cross-domain messaging). It was a little too complicated, so when I explored with Angular, I came across the concept of Angular elements.

I found a git repository ( that shows how an external js file could be used to dynamically load html into your page. I then found blogs and repositories that showed how to create a single bundled JS file external to the main site. For example,

I combined these two examples and ran my main angular application http://localhost:4200 and I created an express app to host external Js files on http://localhost:3000. It worked perfectly.

I couldn't find something similar for React or Vue.js, so maybe I am mixing the wrong terminology? Is this a possibility in React?

json – Saving and exporting information in React

I am developing a very simple application for a friend, in order to end the repetitive part of his activities. The app consists of 3 inputs and 1 button, first I wanted to know if you could create txt or json files in react-native, a way to export the data something like that, as if I created a txt file and gave it by adding a new line for each new interaction with the button, if not, I was looking for localStorage, which apparently stores the information in an internal database if I'm not mistaken.
I was wondering how to export the string or json that I keep in localStorage after collecting data so that it can be processed with a script.
Note: everything will go offline

How to get all the pages of an API and display all the data at once on the screen using React hooks?

Hello, I'm studying React hooks and as a base, I'm using a Rick and Morty API to display characters on screen
However, it only displays twenty characters per page and has a total of 26 pages. I wanted to show the 493 characters on the screen at the same time. I have read the documentation, however, there is no specific request for it. So I tried to make a fodder that ran through all the pages. Right now, when the code is executed, it displays all the characters, but at the end of the loop, there are only the last 20 characters on the last page of the screen . You can see the result here

import React, { useState, useEffect } from 'react';
import { CardGrid, Card } from './tableStyled.js';
import Navbar from '../Navbar/Navbar.js';
import api from '../../services/api.js';

const Table = () => {
  const (characters, setCharacters) = useState(());
  const (numPages) = useState((26));

   useEffect(() => {
     async function loadData() {
       for(var i = 0; i < numPages; i++){
         const apiResponse = await api.get(`?page=` + i);
   }, (numPages)); 

  return (
{ => ( {}

{} {}

{character.species} - {character.status}


); }; export default Table;

javascript – How to navigate this table in React?

I'm using Fetch to post an endpoint that returns the following response:

"movimientos": (
            "Estado": 1,
            "_id": "5e31ee4310ec6117387548a2",
            "usuarios": "5e262750803c451ca4a27c36",
            "empresas": {
                "_id": "5e2f4c3ef80d8246f0e545d8",
                "Nombre_Empresa": "ING. Y HER. S.A."
            "Tipo_Documento": "AF",
            "Numero_Documento": "2",
            "Bodega_Origen": {
                "_id": "5e2619ccbb29d71aa8455cad",
                "Descripcion": "BODEGA PRINCIPAL"
            "Bodega_Destino": {
                "_id": "5e2629f110b9f32d10524ca5",
                "Descripcion": "BODEGA Obra parma"
            "Responsable": "Mauricio",
            "Estado_Documento": "PR",
            "Observaciones": "",
            "Detalles": (
                    "_id": "5e31ee4c10ec6117387548a3",
                    "productos": {
                        "_id": "5e29c1f6bc44ee37687cd976",
                        "Descripcion": "MINICARGADOR No2"
            "Fecha_Creacion": "2020-01-29T20:42:43.535Z"

So far, I have no problem trying to go through the answer to send it to a basic table that I have in view. I showed all the elements without problem. But I need to access this article.

"Detalles": (
                    "_id": "5e31ee4c10ec6117387548a3",
                    "productos": {
                        "_id": "5e29c1f6bc44ee37687cd976",
                        "Descripcion": "MINICARGADOR No2"

Specifically to the value of the description found in the products. I have a simple component that takes care of making the request and displaying the data. The code is as follows:

import React,{Component} from 'react';
import { MDBTable, MDBTableBody, MDBTableHead } from 'mdbreact';

class Movimientos extends Component{
    state = {movimientos: {}}

    componentDidMount () {

            const empresa = {
                _id: '5e2f4c3ef80d8246f0e545d8'

            const options = {
                method: 'POST', 
                headers: {'Content-Type': 'application/json'},
                body: JSON.stringify(empresa)

            fetch('http://localhost:3000/api/movimiento/mostrarMovimientosweb', options
            ).then((res) => res.json())
            .then((data) => { 
                const {movimientos} = data

      "Numero_Documento": "1",
      "Responsable": "Mauricio",
            "Estado_Documento": "PR",
            "Observaciones": "Mas una llanta de repuesto",


    renderMovimientos() {
        const {movimientos} = this.state

  {Object.keys(movimientos).map (datos => {
                 return (
Numero documento Bodega origen Bodega destino Responsable Estado documento Observaciones
Numero documento Bodega origen Bodega destino Responsable Estado documento Observaciones Maquina
{movimientos(datos).Numero_Documento} {movimientos(datos).Bodega_Origen.Descripcion} {movimientos(datos).Bodega_Destino.Descripcion} {movimientos(datos).Responsable} {movimientos(datos).Estado_Documento} {movimientos(datos).Observaciones} {movimientos(datos).Observaciones}
) } render (){ return (
) } } export default Movimientos;

It works fine and brings me the items I ask for, but I couldn't grab the previous item and I'm very sure how I can do it.

javascript – The state value stops updating in the UseEffect hook – Gatsby / React

State value showMenu does not update in useEffect hook.

When testing, when the button is clicked for the first time and the screen is touched to move, showMenu consoles correctly true. When the button is clicked a second time (and third, fourth, etc.) and the screen is touched to move, showMenu continue to console true when it should alternate with false.

const (showMenu, setShowMenu) = useState(false)

useEffect(_ => {
    const listener = e => {
        console.log(showMenu, ' useEffect - touchmove')

        ? document.body.addEventListener('touchmove', listener, {passive: false})
        : document.body.removeEventListener('touchmove', listener)
}, (showMenu))

return (

Console result

enter description of image here

react native – Put the values ​​in the array into state variables

I need to get the information from the json table that comes from the link and put it in a text, here is my current code:

fetch () {
let s = this.state

        .then(function(response) {
            let data = response.json()
            return data;
         .then((json) => {
            console.log('mensagens: ', json)
            this.setState({data : json});
         .catch(function(ex) {
            console.log('parsing failed', ex)
 => (

        s.populacao = populacao

Sorry, I'm new to the native world, can anyone help me?

react.js – A todo application in React using hooks

I am learning React and wanted to implement a todo application using functional components. Any suggestions and criticisms are welcome, especially with regard to best practices.

import React, {useState} from 'react';

class Todo {
    constructor(id, description, complete) { = id;
        this.description = description;
        this.complete = complete;

export default () => {

    const (idCounter, setIdCounter) = useState(1);
    const (todoList, setTodoList) = useState(());
    const (todoDescription, setTodoDescription) = useState('');

    function addTodo() {
            (...todoList, new Todo(idCounter, todoDescription, false))
        setIdCounter(idCounter + 1);

    function markTodoItemComplete(id) {
        const todoListClone = todoList.slice();
        todoListClone(id - 1).complete = true;

    return <>
        { => {
            return (
                    {} - {todoItem.description} - {todoItem.complete ? 'Completed' : 'Waiting'}
); })}
setTodoDescription(} value={todoDescription} />

enter description of image here