Issue with MUI data grid not resizing properly within a grid container: The dimensions of the MUI data grid are not adjusting as anticipated

In my setup, I have a main grid <div> container that contains two child elements. One is the MUI <DataGrid />, and the other is a simple <div>:

Here's how it looks in JSX (React):

<div className="container">
  <DataGrid
    rows={someRows}
    columns={someColumns}
  />
  <div className="somethingElse">
    ...
  </div>
</div>

The CSS for the layout is as follows:

.container {
  display: grid;
  width: 100%;
  grid-template-columns: 3fr 1fr;
}

My expectation is:

  1. The <DataGrid /> and
    <div className="somethingElse">
    should be next to each other, with the <DataGrid /> taking up 3/4 of the total window width, and
    <div className="somethingElse">
    taking up 1/4.
  2. When the user resizes the window, the 3/4 and 1/4 split should remain constant, but both elements should expand or shrink accordingly.

However, in reality: The size of the <DataGrid /> does not change when resizing the window.

I'm wondering if there are any specific styling adjustments needed for the correct behavior of the grid.

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

Protecting against overflow for text inside a container that changes when hovered over

There is text displayed on top of an image within a div container that functions as a link. <a href="https://link.com" style="color:white"> <div class="thumbnail"> <img src="image.jpg" clas ...

5 MUI Autocomplete options narrowed down to display count

Is there a way to retrieve the number of filtered options from the MUI 5 Autocomplete component, without altering the default behavior of the filterOptions prop? ...

What is the best way to stop Quasar dropdown list from moving along with the page scroll?

I am facing an issue with my code while using Quasar (Vue 3.0). The code snippet in question is: <q-select filled v-model="model" :options="options" label="Filled" /> When the drop-down menu is open and I scroll the pag ...

Verify the data types of components received as props in a Typescript React application

I have a question regarding type checking in React components passed as props: What is the method for ensuring that only allowed components are passed as props? Allow me to demonstrate. We have the component we wish to pass around: type CustomProps = { ...

Limiting the input frequency when executing a query with the `urql` GraphQL Client in React.js

My slider functions similarly to this one from Zillow's GitHub. It has minimum and maximum values, and triggers a query whenever the sliders are adjusted. The issue I'm facing is that the query is extensive, causing delays. I am looking for a wa ...

What could be the reason React components are not showing up on the screen?

Exploring the world of react, I decided to experiment with creating a bootstrap template. However, I ran into an issue where react does not recognize the components when compiling. app.js import React from "react"; import { BrowserRouter as Rout ...

What are some ways to align text both vertically and horizontally within columns?

How can I center text both vertically and horizontally inside two columns using Bootstrap 4? <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"> <div class="row"> <div class="co ...

What is the best way to utilize two separate websocket URLs based on the context in react-apollo?

Hey there, I've encountered a problem. Here's the situation: we have two separate graphql servers. I managed to split them by passing context in the query/mutation options. It's all good, but now I also have two different setups for webso ...

NextJS Multilingual ToolBox

I'm working on a NextJS application and I've been trying to integrate the Google auto-translate widget into my app. After creating the following function: function googleTranslateElementInit() { if (!window['google']) { con ...

How to properly center and align the width of a figcaption element within an image placed in a figure element

I've been struggling for two days now trying to fix an issue with the alignment of images and captions on my Django application. In my app, users can upload images, and I'm using figure and figcaption tags to display the image with a caption. Ho ...

When reloading, React fails to load the page properly

I came across a similar question, but I wasn't able to find a clear explanation on how to resolve the issue. All pages on my website, except index.html, fail to load when you refresh the page. Based on the previous query, it seems that using HashHisto ...

By default, the sidebar is open on desktop devices while closed on mobile devices

I am struggling to figure out how to set my sidebar/navigation content, using Bootstrap, to be expanded by default on desktop and closed by default on mobile with the icon only showing on mobile devices. Despite multiple attempts, I cannot seem to make thi ...

When it comes to passing prop values through functions, TypeScript types do not provide suggestions

I'm struggling to find a way to ensure that developers have suggested types for specific props in my component, regardless of how they pass data to the prop. For example, when I directly pass an array of values to the prop: <Component someProp={[{ ...

Anticipated a task or function invocation but encountered an expression instead: no expression left idle

import Alert from '@material-ui/lab/Alert'; export default function MyComponent(props) { let [disabled] = useState(false); const calculateTotal = event => { if (!disabled) { disabled = true; calTotal().then(vali ...

Tips for Uploading Large Images to Backend API in Next.js

As I work on building my portfolio using NextJS, I encountered an issue with the Project Functionality. When converting images to base64 and sending them to an API for uploading on Cloudinary, everything runs smoothly as long as the total size of the req ...

Positioning and resizing elements based on varying screen sizes and levels of zoom

I recently designed a basic webpage using HTML with two main elements - a chat window for user interaction and a chart.js plot. Here is a snippet of the HTML code: <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...

What is the best way to retrieve the reference value from a dropdown box and pass it to another component?

Currently, I am in the process of creating a chat application using socket.io. Within this application, there is a dashboard component that consists of two child components known as Room.js and Chat.js. The Room component serves the purpose of selecting th ...

The twelfth child in the sequence is not functioning properly, although the others are working correctly

In my list, I have 12 elements and each element contains a div. My goal is to set different sizes for each div by using nth-child on the li element. However, the configuration for the 12th element does not seem to work correctly compared to the rest of the ...

reactjs implementation of a virtualized list

Recently, I stumbled upon the React-window library and found it to be incredibly useful. Intrigued by how it was built, I decided to try my hand at creating my own virtualized list. However, I encountered an issue where the list could only scroll up to it ...

Obtaining input value when button is clicked

I am currently working on a feature where, upon clicking the Submit button, I aim to retrieve the value entered into the input field in order to update the h1 element. import React from "react"; function App() { const [headingText, setHeadingT ...