Comments (14)
https://github.com/developit/preact/wiki/Differences-to-React#whats-different
from preact.
Gee, wouldn't it make more sense to make React's behavior the default, and then change behavior if there is a third argument?
from preact.
The second argument is still required. Third argument is the node to replace, second is where to mount.
See this issue: #24
Let me know if that doesn't solve it for you.
- edit -
So your example would be:
let parent = document.getElementById('app');
// call this as often as you want:
render(h(HelloWorld), parent, parent.lastChild);
from preact.
@ayZagen That sounds indeed like an issue. Can you open a new one?
This one is for a different release line and has long been fixed. Even though the symptoms look similar it's probably a different issue. A codesandbox or a repo where the issue can be reproduced is an incredible helpful thing in getting to the bottom of it. Strongly recommend including that 👍
from preact.
I couldn't reproduce issue with only preact. Using Prism.highlightAll()
breaks it. I will look into prismjs and will try to reproduce the issue
from preact.
from preact.
@c2h5oh thanks. It is always all the way down when I look for something.
from preact.
@c2h5oh so I tried render(h(HelloWorld), null, document.getElementById('app'))
but that is giving me
Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
And if I do render(h(HelloWorld), document.getElementById('app'), document.getElementById('app'))
that doesn't render anything.
from preact.
I definitely agree with @qwertie. I am trying to migrate my gatsby site to preact and I couldn't find any way to pass replaceNode argument. I think this line here makes it impossible to pass the argument as gatsby uses preact/compat under hood.
from preact.
@ayZagen React's behaviour has been the default in Preact since the beginning of the 10.x release line, which started more than a year ago. You don't need to pass the third parameter anymore to match that behavior.
from preact.
Thanks for the quick reply. I have tried 10.4.8 and faced with this issue. This is the component:
const HttpSnippet = ({ request, language, codeRef }) => {
const harRequest = createHarFromOpenApiRequest(request, language)
const snippet = new SnippetCreator(harRequest)
const code = snippet.convert(language)
const lineCount = code.split(/\r\n|\r|\n/).length
useEffect(()=>{
Prism.highlightAll()
}, [language])
return (
<>
<div className="line-counts">
{ Array(lineCount).fill().map((count, index) => (<div key={index}>{index + 1}</div>))}
</div>
<pre>
<code className={`language-${language}`} key={language} ref={codeRef}>{ code }</code>
</pre>
</>
)
}
code
element textContent gets duplicated on every rerender
from preact.
@ayZagen Did you ever find out what was causing this issue? I'm seeing something similar to what you're describing.
from preact.
@jakedee sorry, I couldn't dig deep for it and migrated back to react in our gatsby project.
from preact.
@jakedee Can you open a new issue for that?
from preact.
Related Issues (20)
- Make render-function curried HOT 5
- Component don't rerender if prop changes in short period of time HOT 3
- 10.18 regression: setState triggers DOMException: Node.insertBefore: Child to insert before is not a child of this node HOT 12
- Radix UI / Select component in preact HOT 1
- `useId` generates duplicate identifiers in some cases when calling `render` from `@preact/compat` multiple times HOT 3
- Request: setProperty() Export HOT 2
- Add `x_google_ignoreList` (Ignore-listing code) support to sourcemaps HOT 11
- Incorporate preact to NEXTJS. HOT 3
- Focus lost when moving child with `key` HOT 3
- [preact/compat] onTouchMoveCapture not processed
- TS errors for contentEditable attribute
- Aliasing React to Preact in Deno HOT 9
- "Cannot read properties of null (reading '__H')" when hydrating a component in the browser HOT 1
- (question)Is there any practical example of purely using CDN? HOT 5
- TypeError: undefined is not an object (evaluating 'this.l[e.type+!1]') HOT 1
- preact+react-modal,Uncaught TypeError: Cannot read properties of null (reading '__H') HOT 9
- Island architecture with partial hydration HOT 3
- preact renders only one iframe if more than one iframe provided to dangerouslySetInnerHTML HOT 2
- When the value of setState remains unchanged, the state-driven controlled component, such as <input/>, seems to no longer be under the influence of the state. HOT 1
- There is no `context` in `preact/compat/PureComponent` and it breaks other libraries like `react-recurly`
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 preact.