You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when I follow nested route like in example below, I don't want to every time call getInitialProps (because this is a modal, and I don't need every time fetch data )
Page with getInitialProps has Promise.all with 3 promises in it (requests), When I open modal or close I always got these 3 requests
Is there a way to prevent calling getInitialProps when change a route?
thank you
code from readme.md
`// ./src/Detail.js
import React from 'react';
import { Route } from 'react-router-dom';
class Detail extends React.Component {
// Notice that this will be called for
// /detail/:id
// /detail/:id/more "don't want to call getInitialProps"
// /detail/:id/other "don't want to call getInitialProps"
static async getInitialProps({ req, res, match }) {
const item = await CallMyApi(/v1/item${match.params.id});
return { item };
}
The text was updated successfully, but these errors were encountered:
Volodymyrkohut
changed the title
How to prevent call getInitialProps when follow the nested route?
How to prevent calling getInitialProps when follow the nested route?
Jun 1, 2022
❓Question
when I follow nested route like in example below, I don't want to every time call getInitialProps (because this is a modal, and I don't need every time fetch data )
Page with getInitialProps has Promise.all with 3 promises in it (requests), When I open modal or close I always got these 3 requests
Is there a way to prevent calling getInitialProps when change a route?
thank you
code from readme.md
`// ./src/Detail.js
import React from 'react';
import { Route } from 'react-router-dom';
class Detail extends React.Component {
// Notice that this will be called for
// /detail/:id
// /detail/:id/more "don't want to call getInitialProps"
// /detail/:id/other "don't want to call getInitialProps"
static async getInitialProps({ req, res, match }) {
const item = await CallMyApi(
/v1/item${match.params.id}
);return { item };
}
render() {
return (
Detail
{this.props.item}
<Route
path="/detail/:id/more"
exact
render={() =>
/>
<Route
path="/detail/:id/other"
exact
render={() =>
/>
);
}
}
export default Detail;`
The text was updated successfully, but these errors were encountered: