0
const brc = {
 liq : [
{"index":"adc", "fdhsjbs": "12bhsdb"},
{"index":"adc", "fdhsjbs": "12bhsdb"},
{"index":"adc", "fdhsjbs": "12bhsdb"}
] 
};

  const goToPosts = () =>
    navigate({
      pathname: '/posts',
      search: `?${createSearchParams(brc)}`,
    });

  return (
    <div>
      Users
      <button onClick={goToPosts}>Go to Posts</button>
    </div>
  );

While using createSearchParams and passing the properties I am getting an error

Argument of type is not assignable to parameter of type URLSearchParamsInit.

Is there any other possible way when a user clicks on the button pass the brc object to another component based on route setup

  • 1
    Your `brc` const doesn't seem syntactically correct. It has `=` instead of `:` for `liq`. – Brian Thompson Feb 15 '23 at 20:46
  • 2
    Other than the typo/syntax issue, does this help answer your question regarding the queryString? https://stackoverflow.com/questions/72543969/react-router-searchparams-separated-by-comma/72553250#72553250 Or if you just need to pass data from one route to another? https://stackoverflow.com/questions/59701050/how-to-pass-data-from-a-page-to-another-page-using-react-router/59701168#59701168 – Drew Reese Feb 15 '23 at 20:59

0 Answers0