CJY0208 / react-activation

Hack <KeepAlive /> for React
https://www.npmjs.com/package/react-activation
MIT License
1.81k stars 141 forks source link

Bug: Sometimes the tab does not change #228

Closed IsraelDeAraujo closed 1 year ago

IsraelDeAraujo commented 2 years ago

I am having an issue about use the 'KeepAlive' tag. It works well, the perfomance of my App increased so much and I really want to use it. But, sometimes the tab does not change. I am using Ionic Framework with React and building an App. Without the keepAlive, the App works very slowly and ALWAYS the tab change. But with the 'KeepAlive' tag it is faster, but I got this Bug: sometimes the tab does not change and sometimes change.

Here my code (I use it in another four tabs):

import { IonList } from '@ionic/react';

import Input from '../../../../../components/Input';

import PhoneNumber from './phoneNumber';

import KeepAlive from 'react-activation';

function Farmer() {

    return (

        <KeepAlive>
                <IonList lines = 'none'>
                    <Input 
                        title = { 'Nome' } 
                        inputRepeats = { 1 }
                        placeholder = { 'Digite o nome do produtor' } 
                        inputMode = { 'text' }
                    />

                    <PhoneNumber />

                    <Input 
                        title = { 'E-mail' } 
                        inputRepeats = { 1 }
                        placeholder = { 'Digite o e-mail do produtor' } 
                        inputMode = { 'email' }
                    />

                    <Input 
                        title = { 'Fazenda' } 
                        inputRepeats = { 1 }
                        placeholder = { 'Digite o nome da fazenda' } 
                        inputMode = { 'text' }
                    />
            </IonList>
        </KeepAlive>

    );

}

export default Farmer;

And here my code in index.js:

import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
import * as serviceWorkerRegistration from './serviceWorkerRegistration';
import reportWebVitals from './reportWebVitals';
import { AliveScope } from 'react-activation'

const container = document.getElementById('root');
const root = createRoot(container);

root.render(
    <AliveScope>
            <App /> 
    </AliveScope>
);

serviceWorkerRegistration.unregister();

reportWebVitals();

How Can do I certificate my App will change the tab?

CJY0208 commented 2 years ago

There is no problem in the above code. Can you provide online use cases? For example, using codesandbox