I am building a react(redux) applicationwith server side rendering which will have an autocomplete in the first page which the user will type what he wants to find then it will be two cases 1) it will redirect him to the search results if it submits a text he typed. Then from the search results page when he clicks on an item it will redirect him to the items page 2) it will redirect him to the item's page (without going to the results) if he selects an item from the drop down list

Now i've built the component for the autocomplete and the item's page but when i select from the autocomplete the redirection happens but the item is empty (no server call). if you refresh the page, because the redirection happened and failed it loads the item because there is the .need function.FYI i am not using any didLoad or willLoad function on the page component

ItemPage.need = [(params) => { return fetchItem(params.id); }];

You can try to see here https://mymd-api.herokuapp.com/ Type under doctors Κων - then select the first and refresh

What is the right way to do that?

P.S: I was thinking that if the user was coming from a list (search page) then on click i could fetch the clicked item but thats not the case here.

Write your answer…

What i did to solve this is to do a check on componentDidLoad function and check if the props.item is empty or not. If it is then i am fetching from server!