Create a dynamic footer for Netflix using Reactjs

Hey there, I'm currently working on dynamically building the footer of Netflix using Reactjs and styled components. However, I seem to be stuck and could use some assistance. Any guidance would be greatly appreciated :)

I have already created the links in a links.json file

[
  {
    "id": 1,
    "link": "FAQ"
  },
  {
    "id": 2,
    "link": "Investor Relations"
  },
  {
    "id": 3,
    "link": "Privacy"
  },
  {
    "id": 4,
    "link": "Speed Test"
  },
  {
    "id": 5,
    "link": "Help Center"
  },
  {
    "id": 6,
    "link": "Jobs"
  },
  {
    "id": 7,
    "link": "Cookie Preferences"
  },
  {
    "id": 8,
    "link": "Legal Notices"
  },
  {
    "id": 9,
    "link": "Account"
  },
  {
    "id": 10,
    "link": "Ways to Watch"
  },
  {
    "id": 11,
    "link": "Coorporate Information"
  },
  {
    "id": 12,
    "link": "Only on Netflix"
  },
  {
    "id": 13,
    "link": "Media Center"
  },
  {
    "id": 14,
    "link": "Terms of use"
  },
  {
    "id": 15,
    "link": "Contact US"
  }
]

My struggle is with implementing the desired layout for the footer component. Despite trying the filter and map functions, I've been unsuccessful so far. The current result only displays 4 items per column within a ul tag. Any suggestions or solutions are welcome!

import React from 'react'
import linksData from '../fixtures/links' 
import './Footer.css'

function Footer() {
  return (
    // <div>
    //   {linksData
    //     .filter()
    //     .map((item, index)=>(
    //     <li key={index}>{item.link}</li>
    //   )
    //   )}
    // </div>

      
    <div className="site-footer-wrapper">
      <div className="site-footer">
        <p className="footer-top">
          <a className='footer-top-a' href> Questions? Contact US</a>
        </p>
        <ul className='footer-links'>
          <li className='footer-link-item'>FAQ</li>
          <li className='footer-link-item'>Investor Relations</li>
          <li className='footer-link-item'>Privacy</li>
          <li className='footer-link-item'>Speed Test</li>
        </ul>
        <ul className='footer-links'>
          <li className='footer-link-item'>FAQ</li>
          <li className='footer-link-item'>Investor Relations</li>
          <li className='footer-link-item'>Privacy</li>
          <li className='footer-link-item'>Speed Test</li>
        </ul>
        <ul className='footer-links'>
          <li className='footer-link-item'>FAQ</li>
          <li className='footer-link-item'>Investor Relations</li>
          <li className='footer-link-item'>Privacy</li>
          <li className='footer-link-item'>Speed Test</li>
        </ul>
      </div>
    </div>
  )
}

export default Footer

If you have any insights on how to achieve this goal, whether through adjustments in the code logic or CSS styling, your assistance will be highly valued. Thank you!

Answer №1

To maximize efficiency, it's advantageous to segregate the various concerns. By creating a distinct component dedicated to managing each column individually.

In my scenario, I devised a Column component that renders a 'ul' JSX tag and exhibits 'li' JSX tags based on the linksToDisplay array received as props.

const Column = ({ linksToDisplay, key }) => (
   <ul key={key} className='px-4'>
      {linksToDisplay.map((item) => (
         <li key={item.id}>{item.link}</li>
      ))}
   </ul>
);

Subsequently, I incorporate my Column component within my Footer component to showcase the columns in accordance with predetermined criteria.

const Footer = () => {
  return (
    <div className='container mx-auto flex px-2 lg:px-5 py-24 h-screen 
    items-center justify-center flex-row'>
       {links.map((link, index) => {
          // A new column is displayed after every set of 4 items
          if (index % 4 === 0) {
            // Utilize Array.slice to acquire the subsequent 4 links in the array
            const nextFourLinks = links.slice(index, index + 4);
            return <Column key={link.id} linksToDisplay={nextFourLinks} 
             />;
          }
       })}
    </div>
  );
};

Following this, apply appropriate styling to your elements – in my case, I'm leveraging tailwindCSS, resulting in elegantly presented columns showcasing the links.

Output: https://i.sstatic.net/OPGmz.png

For further guidance:

Array.prototype.slice()

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

Unable to load the MicrosoftAjax.debug.js file

My ASP.NET 3.5 web application runs perfectly on my local machine and when deployed on my Windows 2008 server. However, I am encountering a javascript error that states: Error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred ...

Having trouble getting past the initial iteration in Angular's modal system?

Having trouble generating a modal for every iteration in ngFor. The data passed to the modal seems to be stuck in the first iteration and doesn't change with each iteration. Any ideas on how to solve this? <div class="container"> & ...

Tips for updating the bottom color of Material-UI TextField without relying on the <MuiThemeProvider> component

I am facing an issue with a Material UI TextField component that is placed on a dark background. I need to change the text and line colors to red for only this particular instance, while leaving the rest of the TextFields unaffected. My project utilizes @ ...

Unveiling the intricacies of CSS specificity

Struggling with the specificity of this particular CSS rule. Despite researching extensively, I still can't seem to grasp it. Can someone help me determine the specificity of the following: #sidebar h1, p em, p a:hover{ ... } ...

Switch the orientation of the unordered list from horizontal to vertical in a dynamic way

Perhaps a repeated inquiry, yet I have been unable to discover a solution for this issue... I am dealing with a div element (referred to as master) that I do not have the ability to adjust in terms of width or height. Contained within the master is anoth ...

Saving drag and drop positions in Angular to the database and troubleshooting screen resizing problems

Currently, I'm working on an application that involves dragging and dropping a DIV onto an image. My goal is to save the X and Y coordinates of the dropped DIV to the database so that when the user returns, the position will remain the same. The chal ...

Having trouble with sending form data in Express / Node.js?

Apologies if this question seems basic or if it's an obvious mistake, but I'm new to working with Node. Basically, I'm trying to capture a line of text entered by a user in a form on the front end. However, no matter what I try, the result ...

The dynamic form will not display the currency format

Could anyone assist me with this code, please? var sum = parseInt($("#jumlah-form3").val()); var nextform = sum + 1; $("#insert-form3").append( " <tr id='layanan"+nextform+&qu ...

Adjusting the thickness of the CSS cursor line upon entering an input field

Having an image as the background for an input field has been causing issues for me. Although I can adjust the line-height and font-size easily, the cursor line appears outside of the background image when clicking inside the input field. Is there a speci ...

Retrieve image details and display them in the console when the page is resized

Query: How can I retrieve and monitor the src, width, and height of all images on a webpage and display this information in the console whenever the page's size changes? Sample Code Snippet: var images = document.getElementsByTagName('img' ...

What is the best way to combine a navbar with a video background?

Recently, I delved into Bootstrap and attempted to execute a code for a navbar with a video background. This is what my attempt looked like: HTML Code: <html> <head> <title>Medical</title> <meta charset="UTF-8&qu ...

Utilizing the Twitter API 1.1 to retrieve a list of tweets

As I work on updating my CMS component, I am incorporating integration with the Twitter API to fetch and showcase a list of tweets related to a user or search query. I have chosen to utilize the Twitter Restful API v1.1 as the 1.0 version is set to be disc ...

In order to implement the functionality in JavaScript, the .slider::-webkit-slider

I need to create a slider that adjusts the size of the dot based on the value input. For example, when the value is 1, the dot size should be 10px and for a value of 100, it should be 100px. Is there a way to dynamically change the height of .slider::-web ...

How can a Chrome extension transfer an ArrayBuffer or Blob from a content script to the background script without compromising its data type?

In my current script, I am downloading binary data using XHR in the content script and sending it to the background script: let me = this; let xhr = new XMLHttpRequest(); xhr.open('GET', url); xhr.responseType = 'arraybuffer'; xhr.onlo ...

The ng-click event handler is not functioning

var myApp = angular.module('myApp', ['ngRoute']); myApp.config(function($routeProvider) { $routeProvider.when('/', { template: '', controller: 'DefaultController as dc' }).when('/rent& ...

Tips for resolving undefined error handling in node.js

const fileSystem = require('fs'); const fileName = './prices.json'; const file = require(fileName); const price = require('./prices.json'); const fileName = './prices.json'; if(tmd = message.match(/^!change max ...

Create a sleek 2-column design featuring a bonus scroll bar exclusively using CSS styling

In my current project, I have a unique challenge. I am working with a list of flattened div elements and unfortunately, I am unable to edit the HTML markup to add any structures. The first div in the list is quite long, and I would like to place it in a se ...

Setting the view back to the default tab using react-web-tabs

I am currently facing an issue with my default tab setting. In my application, the default tab is set to Income. However, I have a dropdown component on top of the tab that allows users to change the value. Whenever this dropdown value changes, I need th ...

Background extending to full width for the main content area

There seems to be an issue with the background of .main. I am unable to achieve full width for the background. I have reviewed similar questions but couldn't resolve it. Below is my code snippet and fonts for better understanding: Fonts <!DOCYPE ...

Error in React Component Library: The identifier 'Template' was not expected. Instead, '}' is expected to end an object literal

I've embarked on the exciting journey of creating my own React component library. Utilizing a helpful template found here, I've shaped the latest iteration of my library. To test its functionality, I smoothly execute the storybook with yarn stor ...