question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Grid.useBreakpoint is empty on initial render

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  1. consume Grid.useBreakpoint();
  2. initial render will display empty object

What is expected?

I would expect Grid.useBreakpoint() to return an initial value on the first render. This could also potentially not rerender a component consuming Grid.useBreakpoints().

You could initiate it by checking window.innerWidth on mount.

I would be happy to create a PR for this.

What is actually happening?

initial render of Grid.useBreakpoint() displays an empty object

Environment Info
antd 4.16.13
React 17.0.2
System macOs BigSur
Browser Firefox 93.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
zombieJcommented, Oct 19, 2021

This is by design since first render with screen info will break SSR hydrate.

0reactions
GeorgeFloriancommented, Nov 15, 2022

This is by design since first render with screen info will break SSR hydrate.

I see, but if I don’t use SSR, how can I make my own hook that doesn’t return undefined on the first render?

Have you found a solution to this ? I am also in need to know the breakpoint on initial render.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to get initial breakpoint using react-grid-layout?
Example of props that are available once rendered. <ResponsiveGridLayout autoSize: ... initialBreakpoint === null) { // The very first time.
Read more >
Developing responsive layouts with React Hooks
We are going to use React Hooks to create an elegant and, more importantly, reusable solution to the problem of creating responsive layouts ......
Read more >
SSR for multiple breakpoints using React - DEV Community ‍ ‍
Boundaries class names are set during hydration render (server and first client render), so this behaviour is controlled by the state. Variable ...
Read more >
Grid - Ant Design
24 Grids System. ... Layout uses a 24 grid layout to define the width of each "box", ... Use useBreakpoint Hook provide personalized...
Read more >
jtable is blank and empty - MSDN - Microsoft
i write certain piece of code using mvc 4 and jquery and jtable ,but data is not visible in grid ,only blank grid...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found