preact-cli icon indicating copy to clipboard operation
preact-cli copied to clipboard

Double render

Open devalexandre opened this issue 5 years ago • 6 comments

When use preact_root

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title><% preact.title %></title>
		<meta name="viewport" content="width=device-width,initial-scale=1">
		<meta name="mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<link rel="apple-touch-icon" href="./assets/icons/apple-touch-icon.png">
		<% preact.headEnd %>
	</head>
	<body>
<div id="preact_root"></div>
	<% preact.bodyEnd %>
	</body>
</html>

devalexandre avatar Apr 11 '20 15:04 devalexandre

This is happening because you have 2 elements with the ID preact_root. When Preact boots up, it gets a reference to the first one, which is the empty duplicate you created here.

You can address this by removing the bodyEnd block.

developit avatar Apr 13 '20 22:04 developit

but if you remove the bodyEnd, it will not fail to load the .js that are generated dynamically?

devalexandre avatar Apr 15 '20 13:04 devalexandre

why do we want <div id="preact_root"></div> in the markup

prateekbh avatar Apr 15 '20 21:04 prateekbh

for do SSR with preact

template ssr

devalexandre avatar Apr 16 '20 01:04 devalexandre

for do SSR have get root tag for render components, have somebody to remove double render?

devalexandre avatar Apr 26 '20 15:04 devalexandre

here, get a preact_root, but uf I use this id double render https://github.com/preactjs/preact-cli/blob/master/packages/cli/lib/lib/entry.js#L39

devalexandre avatar May 03 '20 04:05 devalexandre