Surprising Media Component Found in URL Parameters within the design

Exploring the page structure of my Next.js project: events/[eventId]

Within the events directory, I have a layout that is shared between both the main events page and the individual event pages(events/[eventId]). The layout includes a simple video background. However, there seems to be an issue where sometimes when transitioning from the main event page to a specific event page (event/[id]), the URL parameters for the specific event page shows an element with src or poster attributes. This behavior is puzzling and I am seeking guidance on how to resolve it.

Any assistance or insights on fixing this situation would be highly appreciated!

Code snippet from events/layout.tsx:

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <>
        <BackgroundVideo />
            {children}
    </>
    
  );
}

Pertaining to the BackgroundVideo component:

"use client"

import { useEffect,useState } from "react";

const BackgroundVideo = () => {
  const [isClient, setIsClient] = useState(false);

  useEffect(() => {
    setIsClient(true)
  },[])

  return(
    <div >
      {
      isClient && 
      <video 
        autoPlay loop muted
        poster="videoBgPoster.jpg"
        >
          
      <source src="videoBg.mp4" 
              type="video/mp4"/>
      </video>
      }
      <div className="z-[-90] fixed bg-black bg-opacity-40 h-full w-full"></div>
    </div>
  );
}

export default BackgroundVideo;

Further details about events/[eventId]:

type Props = {
  params: {
    eventId: string,
  },
  searchParams: Record<string, string> | null | undefined
}

const Event = async ({ params, searchParams }: Props) => {

  console.log("Params...: ", params)
}

The issue occurs intermittently with correct and incorrect id values being displayed in the URL parameters.

Console output:

Params...: { id: 'videoBgPoster.jpg' } Params...: { id: 'videoBg.mp4' }

Answer №1

It seems like the issue lies in how the video src paths are formatted. Using absolute paths such as /videoBgPoster.mp4 seemed to resolve the problem.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieve data from the Redux store within the getServerSideProps function in NextJS

I'm trying to access my Redux store in the getServerSideProps() function of my Next.js app to retrieve the user id stored in the Redux Store and preload user data. I have successfully implemented this on the client side using next-redux-wrapper, but w ...

Generating references dynamically without the use of strings

UPDATE: Our current React version is 16.2.0, which is important for this question (check out this answer). From what I understand, this is the recommended way to create a ref in our React version: <div ref={(r) => { this.theRef = r; }}>Hello!< ...

Is it possible for my node.js to become unresponsive when comparing lists?

In my node.js app, I have two lists - one retrieved from a database and the other created by listing file names on a server. Both lists contain approximately 750,000 strings each, and now I need to search for each string in one list within the other. As a ...

Is there a way to trigger an AJAX request right before I leave the page or unload it?

When the window is about to be unloaded, an AJAX request is sent to a specific URL including the recent tracking ID and the time spent on the page in seconds. However, the behavior I am experiencing is an alert displaying [object Object]. ...

Vue3 is struggling to apply dynamic styling exclusively to certain buttons

Currently, I am diving into the world of vue and facing a challenge in styling buttons dynamically when clicked individually. These buttons serve as filters for a list of products, and my goal is to apply one style when the filter is 'on' and ano ...

Tips for styling tooltips in rc-slider

I am currently using the react library rc-slider and I am looking to add a tooltip feature to display the current value. I found guidance on how to do this from a post on the rc-slider GitHub page. However, I encountered an issue where my slider position b ...

Is there a way to dynamically update the content of <li> tag with values from an array every x seconds

I am trying to create a li list using jQuery that will update every 2 seconds with new content, similar to game news updates. However, I'm encountering an issue during the first cycle where it skips the second item in the array. The subsequent cycles ...

Vue: Storing selected list values in an array

I am working on a Vue application where I need to select two elements from a list component and place them inside an array. Currently, I have my list set up with selection functionality thanks to Vuetify. I have bound the selected items to an array using v ...

What is the rationale behind placing the CSS outside of the React function components, near the imports?

Recently, I encountered an issue with loading CSS inside a React function component using Material UI. Even though I managed to resolve it, I am still intrigued by the underlying reason. Initially, I had something like this setup where I placed both makeSt ...

Discover the method of obtaining the post id within an Ajax callback in the Wordpress

Currently, I am using the Add to cart Ajax callback, but I am facing difficulty in retrieving the post Id from it. MY OBJECTIVE: My intention is to apply the add_filter only on a specific page. Here is the PHP code in functions.php file: add_filter( &apos ...

Ways to transform a PHP function into one that can be invoked using Ajax

In my current project, I’m facing an issue where I need to call multiple PHP functions that output HTML using Ajax. Instead of directly trying to call a PHP function with Javascript, I believe application routing can help the frontend hit the correct fun ...

Should I install both dependencies for Moment.js Plugins?

Thinking about incorporating a moment.js plugin such as moment-business-days. Do I need to install both packages? npm install moment-business-days npm install moment // yes / no / maybe? Or is it sufficient to just install the plugin since it already inc ...

How to upload an Image to Cloudinary using Express.js, React, and Axios for a POST

I encountered an issue while attempting to upload images to Cloudinary using a React front-end and Express server. The problem lies in not being able to properly post request the image to my Express server. Here is how I prepare the image for sending it l ...

Issue: The login.component.html file failed to load

I attempted to utilize a custom-made HTML file with the templateUrl attribute in Angular2. Below is the content of my login.component.ts file: import {Component} from '@angular/core'; @Component({ selector: 'login' , template ...

Configuring webpack in Next.js can be done through the `next.config.js` file

I am currently utilizing NextJS and incorporating the react-data-export plugin for generating xls files. The description of the plugin mentions: This particular library makes use of file-saver and xlsx, and by integrating json-loader, the desired functio ...

Identify the difference between a regular function and a constructor in JavaScript

How can we determine whether a function in javascript is a simple, plain (anonymous) function, or a constructor (a function with a prototype)? I have developed the following function for this purpose: function checkFunctionType(value) { var ownPropert ...

How can I update data in Select2 after it has been initialized?

After initializing select2, I am trying to set an array of data in the following way: var selection = $('#selection').select2({}); selection.data([ {id: 1, text: 'value1'}, {id: 1, text: 'value1'} ]); However, I am encou ...

Reconfigure the Node application using Express to seamlessly access modules through route files

I recently created a basic app using npm express. After generating the app.js file, I attempted to add new modules but encountered an issue where I couldn't access them in the route files. For example, when trying to utilize the 'request' mo ...

Sending data from PHP to JavaScript using AJAX

I'm encountering an issue trying to pass data from a PHP file to a JavaScript file using echo. My PHP file contains the following code snippet: <?php ...establishing connection and retrieving list from database... for($i=0;$i<sizeOf($li ...

Develop an innovative showcase page showcasing 151 individual profiles with React Router

I am new to using React Router and feeling a bit confused about how to proceed. On my homepage, I have 151 unique monster thumbnails. When a user clicks on a thumbnail, they should be directed to the specific monster's 'show page'. Currently ...