Giter Club home page Giter Club logo

denvudd / react-dbmovies.github.io Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 1018 KB

A TMDB-inspired application. Search for movies, TV shows, or actors, rate them, create lists for yourself and friends, and discover new things about the world of cinema.

Home Page: https://react-dbmovies.vercel.app

JavaScript 0.24% SCSS 13.22% TypeScript 86.54%
nextjs react redux-toolkit typescript ant-design dayjs numeraljs react-content-loader react-youtube rtk-query react-markdown ahooks fast-average-color react-jest react-testing-library

react-dbmovies.github.io's Introduction

This is an open source The Movie Database clone build with Next.js 13. It is bootstrapped with create-next-app. You can track changes, ideas, and notes on the Trello board of the project.

The Movie Database Clone

Warning This project is still in development and is not ready for production use.

It uses new technologies (experimental-edge) which are subject to change and may break your application.

Tech Stack

Installation

1. Clone the repository

git clone [email protected]:denvudd/react-dbmovies.github.io.git

2. Install dependencies

npm install

3. Create .env file for your TMDB Api Key

4. Run the application

npm run dev

5. Run tests

npm run test

How do I deploy this?

Follow the deployment guides for Vercel and Netlify for more information.

License

No license.

Contributing

Contributions are welcome! Please open an issue if you have any questions or suggestions. Your contributions will be acknowledged.

react-dbmovies.github.io's People

Contributors

denvudd avatar

Stargazers

 avatar

Watchers

 avatar

react-dbmovies.github.io's Issues

Long initial page load with dynamic routing and getServerSideProps

When accessing the page with movie details the initial page load can take up to 7 seconds. After the first load, the page loads normally (around 2 seconds). This is not the expected behavior.

The page uses getServerSideProps, inside which a data request is initialized using RTK Query with the next redux wrapper. After fetching the data, the page component calls useQuery to subscribe to updates and retrieve the data (there is no second request because it was already initialized in getServerSideProps). The data is then passed to the MovieDetailsBlock component for display.

The reason for the slow initial load is currently unknown. During the page load, in DevTools Network, a simple JSON file can be seen in a pending state. After a minute, the page is presumably cleared from the cache, and upon subsequent visits, it loads slowly again, indicating that the slow load only occurs on the first load of the page component.

Current package.json:

{
  "name": "react-tbmovies",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@ant-design/icons": "^5.0.1",
    "@reduxjs/toolkit": "^1.9.5",
    "@types/node": "20.1.3",
    "@types/react": "18.2.6",
    "@types/react-dom": "18.2.4",
    "ahooks": "^3.7.7",
    "antd": "^5.4.7",
    "classnames": "^2.3.2",
    "clipboard": "^2.0.11",
    "dayjs": "^1.11.7",
    "lodash.debounce": "^4.0.8",
    "next": "13.4.2",
    "next-redux-wrapper": "^8.1.0",
    "numeral": "^2.0.6",
    "react": "18.2.0",
    "react-content-loader": "^6.2.1",
    "react-dom": "18.2.0",
    "react-redux": "^8.0.5",
    "react-youtube": "^10.1.0",
    "sass": "^1.62.1",
    "typescript": "5.0.4"
  },
  "devDependencies": {
    "@types/lodash.debounce": "^4.0.7",
    "@types/numeral": "^2.0.2"
  }
}

Page component [id].tsx:

import React from "react";
import DetailLayout from "@/layouts/DetailsLayout";
import MovieDetailsBlock from "@/components/MovieDetailsBlock/MovieDetailsBlock";
import {
  getMovieDetails,
  getRunningQueriesThunk,
} from "@/redux/api/movies/slice";
import { wrapper } from "@/redux/store";

interface MovieDetails {
  id: number;
}

export const getServerSideProps = wrapper.getServerSideProps(
  (store) => async (context) => {
    const { id } = context.query;

    if (typeof id === "string") {
      await store.dispatch(
        getMovieDetails.initiate({ id, params: "language=uk-UA&page=1" })
      );
    }

    await Promise.all(store.dispatch(getRunningQueriesThunk()));

    return {
      props: { id: id },
    };
  }
);

const MovideDetails: React.FC<MovieDetails> = ({ id }) => {
  const { data } = getMovieDetails.useQuery({
    id,
    params: "language=uk-UA&page=1",
  });

  return (
    <>
      <DetailLayout>
        {data && <MovieDetailsBlock id={id} data={data} />}
      </DetailLayout>
    </>
  );
};

export default MovideDetails;

DevTools Network during page load:

  1. Pending state for JSON:
    image

  2. Fulfilled state for JSON and call information:
    image

Relative links for this issue:
Super slow page load times in development environment
First call to getServerSideProps is slow
Slow initial page load with getServerSideProps

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.