Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'data-reactroot' attribute missing in 16.0.0 #10971

Closed
carruthe opened this issue Sep 29, 2017 · 5 comments
Closed

'data-reactroot' attribute missing in 16.0.0 #10971

carruthe opened this issue Sep 29, 2017 · 5 comments

Comments

@carruthe
Copy link

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
With versions prior to 16, React added a 'data-reactroot' attribute to the generated div wrapping the render. I rely on this attribute in order to select the div with css (in my case to make it height 100% so it fills its container).

e.g.
#root > [data-reactroot] { height: 100%; width:100%; }

With version 16, this attribute no longer appears, and I can't easily select the div with CSS. I can hack it in Javascript, but it was a lot cleaner with the 'data-reactroot' attribute.

Before version 16

reactroot-pre16

##After Version 16
reactroot-gonewith16

@iamdustan
Copy link
Contributor

This is an intentional change. https://hackernoon.com/whats-new-with-server-side-rendering-in-react-16-9b0d78585d67 [data-reactroot]was an implementation detail.

You can add your own id or className hook for that on your root component to accomplish.

@krizzu
Copy link

krizzu commented Sep 29, 2017

Hey @carruthe,

You can use selector #root div:first-child { height: 100%; width:100%; } to match first div under #root

@TrySound
Copy link
Contributor

TrySound commented Sep 29, 2017

Or even spread your app component

render() {
  return (
    <div style={{ position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 }}>
      My App
    </div>
  );
}

@aweary
Copy link
Contributor

aweary commented Sep 29, 2017

Sorry if it unexpectedly broke anything for you @carruthe! As mentioned it was an implementation detail which shouldn't have been used, though we understand that's easier said than done 😄 The suggestions listed above are hopefully good solutions for you.

@gaearon maybe we should add a note about this to the v16 blog post? I'm sure there are others who have been relying on those attributes.

@aweary aweary closed this as completed Sep 29, 2017
@carruthe
Copy link
Author

carruthe commented Oct 3, 2017

@aweary - Thanks - I understand, it's the risk one takes when using undocumented features! The suggestion from @TrySound worked for me. Thanks!

Judahmeek added a commit to reactjs/react-rails that referenced this issue Jul 20, 2023
Judahmeek added a commit to reactjs/react-rails that referenced this issue Jul 21, 2023
Judahmeek added a commit to reactjs/react-rails that referenced this issue Jul 21, 2023
Judahmeek added a commit to reactjs/react-rails that referenced this issue Jul 25, 2023
Judahmeek added a commit to reactjs/react-rails that referenced this issue Jul 27, 2023
* Upgrade react

* Upgrade depenencies

* new react source

* remove assertions on data-reactroot

see facebook/react#10971

* use React v18's root API

* add TextEncoder library

* use node polyfill plugin & fast-text-encoder

see shakacode/react_on_rails#1457 (comment)

* entry for #1290

---------

Co-authored-by: Mostafa Ahangarha <[email protected]>
Oleksandr0305 added a commit to Oleksandr0305/react-rails that referenced this issue Feb 1, 2025
* Upgrade react

* Upgrade depenencies

* new react source

* remove assertions on data-reactroot

see facebook/react#10971

* use React v18's root API

* add TextEncoder library

* use node polyfill plugin & fast-text-encoder

see shakacode/react_on_rails#1457 (comment)

* entry for #1290

---------

Co-authored-by: Mostafa Ahangarha <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants