react history

BackEnd_Ash.log·2022년 5월 17일
0

react

목록 보기
41/41

✅ react history

App.js

const App = () => {
  return (
    <div>
      <Router>
        <Layout>
          <Switch>
            <Route exact path="/movies/:movieId" component={DetailMoviePage} />
          </Switch>
        </Layout>
      </Router>
    </div>
  );
};
export default App;

Page.js

  const testClick = (dataId)=> {
    console.log(dataId);
    history.push({
      pathname: `/movies/${dataId}`,
      state: dataId,
    });
  }

  return (
		...
      {movies.length > 0 &&
        movies.map((movie) => (
          <Card style={{ margin: "20px", board: "none" }}
                onClick={() => testClick(data.id)}
          >
	   ...
  );
};
profile
꾸준함이란 ... ?

0개의 댓글