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

Satelites and center content badly positioned on fresh CRA 5 / React 18.2 project (styles are missing) #11

Open
alex-kowalczyk opened this issue Oct 19, 2022 · 3 comments

Comments

@alex-kowalczyk
Copy link

alex-kowalczyk commented Oct 19, 2022

After upgrading from React 16.8/react-scripts 4 to 18.2/5, Planet stopped to properly position the orbital system. "Satellites" are put in a vertical row, "Center content" is put as the last item.

Minimal reproduction scenario:

  1. Initialize react app (ensure using latest cra 5.0.x; if installed before via npm install -g then remove)
npx create-react-app r18
cd r18
npm install --save react-planet@1.0.1
  1. Inspect package.json to ensure the app uses react 18.2.x and react-scripts 5.x

  2. Edit default App.js, adding a simple planet with 2 satellites

import {useState} from 'react';
import {Planet} from 'react-planet';
import './App.css';

function App() {
  const [open, setOpen] = useState(false);
  return (
    <div className="App">
      <header className="App-header">
        <Planet bounceOnClose orbitRadius={60} hideOrbit
                open={open} onClick={() => setOpen(true)} onClose={() => setOpen(false)}
                centerContent={<div style={{border: '1px solid white'}}>Center</div>}
        >
            <div style={{border: '1px solid white'}}>1</div>
            <div style={{border: '1px solid white'}}>2</div>
        </Planet>
      </header>
    </div>
  );
}

export default App;

Expected result: nice orbital system
Actual result: heavily mispositioned.
image

Seems that makeStyles-root-X are not defined in output code, resulting in missing z-index and position:absolute styles. This makes top and left styles inactive (on screenshot - grayed out with tooltip "top has no effect on this element since it’s not a positioned element. Try setting its position property to something other than static.")

image

@dns-entity
Copy link

I got the same problem. I didn't find the right solution, but I found that "z-index" and "position: absolute" are successfully applied when <React.StrictMode> is disabled. The planets fall into place :)

@ephraimrothschild
Copy link

I got the same problem. I didn't find the right solution, but I found that "z-index" and "position: absolute" are successfully applied when <React.StrictMode> is disabled. The planets fall into place :)

This works, but I feel like this shouldn't be the correct way to do this

@averwhy
Copy link

averwhy commented Sep 6, 2024

Also having this problem and i can confirm StrictMode is breaking it.

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

4 participants