Comments (4)
Hi @LucaDillenburg !
Thank you for the response. I should have definitely defined the problem better in my first post.
The custom element specifically is a html custom element . I'll update the title to reflect this as well.
The specific thing that causes the renderToString
/renderToStaticMarkup
to diverge is the hyphen (-
). You can see the logic here.
I found the easiest way to reproduce would be to add a test case to ReactServerRendering-test.js . The test cause would be:
it('children should be rendered for custom elements', () => {
const output = ReactDOMServer.renderToString(
<my-custom-element-a>
<my-custom-element-b></my-custom-element-b>
</my-custom-element-a>,
);
expect(output).toBe(`<my-custom-element-a><my-custom-element-b></my-custom-element-b></my-custom-element-a>`);
});
The above will fail, as the output is actually <my-custom-element-a></my-custom-element-a>
because children are skipped during the server rendering.
from react.
I believe this was just fixed in #27511! This fix will be in the next release and you can also use the latest canary build (I verified it outputs <custom-element-a><custom-element-b></custom-element-b></custom-element-a>
.)
from react.
Thank you all for the help here 🙏
from react.
Hello @emmclaughlin !
I've tried to reproduce your issue, but couldn't yet. Can you provide a minimal reproduction?
For now, this is what I've tested:
import ReactDOMServer from "react-dom/server";
const CustomElementA = ({ children }) => (
<div>
<h1>Hello World</h1>
{children}
</div>
);
const CustomElementB = ({ children }) => <p>This is a text description.</p>;
const customElements = (
<CustomElementA>
<CustomElementB></CustomElementB>
</CustomElementA>
);
export const staticMarkup = ReactDOMServer.renderToStaticMarkup(customElements);
console.log(staticMarkup);
console.log(ReactDOMServer.renderToString(staticMarkup));
The result is both custom elements being printed:
<div><h1>Hello World</h1><p>This is a text description.</p></div>
from react.
Related Issues (20)
- Replace "Donate to Ukraine" Banner with "Support Palestine" in ReactJS HOT 5
- useFormStatus only works from within the scope of the form it relates to HOT 8
- Bug: The solution for challenge 2 (Fix a retriggering animation) is an overkill. https://react.dev/learn/removing-effect-dependencies#challenges HOT 4
- Bug: Found an error on React Documentation Site HOT 1
- Bug: Cannot read properties of null (reading 'useState') HOT 6
- [DevTools Bug]: Console.log in second call to useMemo callback in strict mode is not dimmed or suppressed HOT 2
- [DevTools Bug]: `sayHelloToBackendManager` continuously and pointlessly polls on every page HOT 4
- just out of curiosity, why the latest version of task scheduler stop using requestAnimationFrame? Thanks for the answers~ HOT 1
- Bug:
- [DevTools Bug]: There is a problem with the scrollbar in https://react.dev/learn/ HOT 10
- Feature Request: Allow executable `script` tags HOT 4
- [DevTools Bug]: react-devtools depends on vulnerable versions of electron and got HOT 3
- Component passing deep down via context api but supported out of the box HOT 2
- Bug: `use()` Delays Loading in Unrelated Components, Suspense Waits for Unrelated `use()` Calls
- Bug: Controlled `<select>` form cannot enforce the specified "value" on iPad. HOT 2
- The error was thrown at https://ga.jspm.io/npm:[email protected]/standalone.js:51:335451 at ee.emit (https://ga.jspm.io/npm:[email protected]/standalone.js:51:281929) at https://ga.jspm.io/npm:[email protected]/standalone.js:51:283476 at https://ga.jspm.io/npm:[email protected]/standalone.js:51:679409 at Array.forEach (<anonymous>) at Am.$.onmessage (https://ga.jspm.io/npm:[email protected]/standalone.js:51:679392)[DevTools Bug] Cannot add node "1" because a node with that id is already in the Store. HOT 1
- [ReadToPipeableStream] Support { end: false } Options as second param
- [DevTools Bug] Could not find node with id "24823" in commit tree HOT 1
- Bug: Infinite loop with useState and useEffect hooks HOT 9
- Bug:
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.