Comments (7)
Can you give me a vague overview of your app’s element tree and how the order differs in React? That’d be very helpful 🙌
I suspect it may be related to something being skipped over or to a minor difference. At least that’s what I’m hoping.
Are your UIDs order-based? And how are they being created?
from react-ssr-prepass.
Hiya 👋 do you have any reproduction or more details please? Otherwise I’ll have to close this issue for now due to inactivity
from react-ssr-prepass.
Hi, Sorry for the late reply!
I have a main React tree with which is always rendered in the same order. From those "main components" I have text clamping components which are given a unique ID (for server/client id matching). Those components are ran afterwards with react-ssr-prepass
, but on server/client actual rendering they are ran earlier alongside main components.
Do you have any idea?
Not sure how I can give you more info...
Thank you 🚀
from react-ssr-prepass.
That’s unfortunately not more information to go on 😅
With this given information, I’d simply have to test all possible rendering order discrepancies, which is impossible. I’m also not aware of anything that can cause this that isn’t intended behaviour.
So without a reproduction or any specific cause I can’t actually reproduce this and drill this down
from react-ssr-prepass.
Closed due to inactivity
from react-ssr-prepass.
I see also a diff in rendering order.
I have this implementation
import React, { useState } from "react";
interface SampleProps {
name?: string;
}
class Home extends React.Component<SampleProps> {
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(props: SampleProps) {
super(props);
}
fetchData = function (props) {
console.log("Home -> fetchData -> fetchData", props);
return fetch("https://google.se");
};
render() {
console.log("Home " + this.props.name)
return <h1>Hello {this.props.name}</h1>;
}
}
const Home2 = (props) => {
const { name } = props;
console.log("Home2 " + name)
return <h1>Hello, {name} <Home name={"inne" + name} /></h1>;
};
Home2.fetchData = function (props) {
console.log("Home2 -> fetchData -> fetchData", props);
return fetch("https://google.se");
};
const App = () => {
const [v, sv] = useState<any>("gsl");
console.log("App -> App")
return (
<div className="App" onClick={() => sv("a")}>
<Home name="1" />
<Home2 name="2" />
<Home name="3" />
<Home2 name="4" />
</div>
);
};
export default App;
On server
await ssrPrepass(element, (element, instance) => {
if (element && element.type && element.type.fetchData) {
return element.type.fetchData(element.props);
} else if (instance && instance.fetchData) {
return instance.fetchData(element.props);
}
});
// outputs
App -> App
Home 1
Home2 2
Home 3
Home2 4
Home inne2
Home inne4
renderToString(element);
// outputs
App -> App
Home 1
Home2 2
Home inne2
Home 3
Home2 4
Home inne4
from react-ssr-prepass.
@codler that does look like expected behaviour to me. Once you start suspending you have concurrent processes ongoing. So for each sub tree and path the render order in react-ssr-Prepass
will be consistent to React, but given that one is tree suspends another parallel one can still continue to be rendered.
So this timing changes the render order in your case as data becomes available.
If this wouldn't be done, a Prepass overhead would be quite huge and unparallelised
from react-ssr-prepass.
Related Issues (20)
- Throws "ReferenceError: setImmediate is not defined" in browser HOT 2
- React 17 RFC and future maintenance HOT 2
- Relationship to more "full-featured" SSR libraries? HOT 1
- Functional components HOT 5
- React 17 support HOT 1
- Provide ESM build HOT 1
- Compatible with apollo@3 hooks ? HOT 2
- using ssr-prepase after 1.3.0 react 17 HOT 3
- Example with vite-plugin-ssr HOT 4
- React 18 support useId
- Functional Components HOT 1
- Question: Some libraries cannot seemingly clear data in custom derivate...
- Potential bug with wrapped components?
- React 18 shim HOT 3
- v1.5.0 Missing from Github HOT 1
- Guard/check missing in areHooksInputEqual()?
- why HTML node showing empty or undefined? HOT 1
- Add useInsertionEffect to the dispatcher
- `Visitor` callback `element` argument is typed incorrectly in TypeScript
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-ssr-prepass.