Skip to content

Tag: reactjs

How to add value to Map initialized in state using react?

I have application and i need to keep search history, in my opinion Map is suitable here: to update it use setSearchHistory(new Map([[text, result.repos]])); but it replaces Map with new Map, could you please tell me how can i add value to Map initialized in state ? Answer State updater function returned by u…

I want to redirect to a new page on react on a conditon

Error:Line 33:13: Expected an assignment or function call and instead saw an expression no-unused-expressions I used the Route and Browser Router to create the link to the page. I need to redirect to the home page on signing in. Answer As you are not using state anywhere, you can add redirect instead of setti…