Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: React router not changing props #19986

Closed
victororlyk opened this issue Nov 24, 2019 · 2 comments
Closed

bug: React router not changing props #19986

victororlyk opened this issue Nov 24, 2019 · 2 comments
Labels
package: react @ionic/react package

Comments

@victororlyk
Copy link

Bug Report

Ionic version:

[x] 4.6.3

Current behavior:

The router render is passing props only one time and remember the value not changing.If we click on button on page3 it should have passed new props to the component but it doesn't
Expected behavior:

on button click it should change name state and pass to the component new props;
Steps to reproduce:

Related code:

app.tsx

const App: React.FC = () => {
  const [name, setName] = useState('Viktor');
  return (
    <IonApp>
      <IonReactRouter>
        <IonTabs>
          <IonRouterOutlet>
            <Route path="/tab3" render={(props: any) => <Tab3 {...{ name, setName}} />}/>
            <Route path="/" render={() => <Redirect to="/tab1" />} exact={true} />
          </IonRouterOutlet>
          <IonTabBar slot="bottom">
            <IonTabButton tab="tab3" href="/tab3">
              <IonIcon icon={send} />
              <IonLabel>Tab Three</IonLabel>
            </IonTabButton>
          </IonTabBar>
        </IonTabs>
      </IonReactRouter>
    </IonApp>
  );
}

tab3.tsx

import React from 'react';
import { IonHeader, IonToolbar, IonPage, IonTitle, IonContent, IonButton } from '@ionic/react';


interface Tab3Props{
  name: string,
  setName: Function
}
const Tab3Page: React.FC<Tab3Props> = ({name, setName}) => {
  return (
    <IonPage>
      <IonHeader>
        <IonToolbar>
          <IonTitle>Tab Three</IonTitle>
        </IonToolbar>
      </IonHeader>
      <IonContent >
        <IonButton onClick={()=>setName('another')}>
          {name}
        </IonButton>
      </IonContent>
    </IonPage>
  );
};

export default Tab3Page;

Other information:

Nov-24-2019 10-45-56
Ionic info:


@ionitron-bot ionitron-bot bot added the triage label Nov 24, 2019
@victororlyk victororlyk changed the title bug: React router bug: React router not changing props Nov 24, 2019
@liamdebeasi liamdebeasi added the package: react @ionic/react package label Nov 25, 2019
@ionitron-bot ionitron-bot bot removed the triage label Nov 25, 2019
@elylucas
Copy link
Contributor

fixed in 4.11.6

@ionitron-bot
Copy link

ionitron-bot bot commented Jan 10, 2020

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Jan 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: react @ionic/react package
Projects
None yet
Development

No branches or pull requests

3 participants