Store recent user’s searches

Viewed 19

I’m fetching data from GitHub API and I have a search and submit button. So basically after each user search I want to store the search name to another page that I have built. That is how I am getting the data:

const handleSubmit = (e: React.MouseEvent<HTMLElement>) => {
    axios
      .get(`https://api.github.com/users/${inputText}/repos`)
      .then((response) => {
        setData(response.data);
      })
      .catch((error) => {
        console.log('error', error);
      })
  };

inputText is basically what I want to store or the e.target.value otherwise from search component?

What is the best way to approach it? Use local storage somehow or React useContext?

Any help would be appreciated!

0 Answers
Related