Giter VIP home page Giter VIP logo

Comments (14)

c2h5oh avatar c2h5oh commented on April 30, 2024 3

https://github.com/developit/preact/wiki/Differences-to-React#whats-different

from preact.

qwertie avatar qwertie commented on April 30, 2024 3

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.

developit avatar developit commented on April 30, 2024 2

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.

marvinhagemeister avatar marvinhagemeister commented on April 30, 2024 1

@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.

ayZagen avatar ayZagen commented on April 30, 2024 1

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.

jakedee avatar jakedee commented on April 30, 2024 1

@marvinhagemeister - #3236

from preact.

capaj avatar capaj commented on April 30, 2024

@c2h5oh thanks. It is always all the way down when I look for something.

from preact.

capaj avatar capaj commented on April 30, 2024

@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.

ayZagen avatar ayZagen commented on April 30, 2024

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.

marvinhagemeister avatar marvinhagemeister commented on April 30, 2024

@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.

ayZagen avatar ayZagen commented on April 30, 2024

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.

jakedee avatar jakedee commented on April 30, 2024

@ayZagen Did you ever find out what was causing this issue? I'm seeing something similar to what you're describing.

from preact.

ayZagen avatar ayZagen commented on April 30, 2024

@jakedee sorry, I couldn't dig deep for it and migrated back to react in our gatsby project.

from preact.

marvinhagemeister avatar marvinhagemeister commented on April 30, 2024

@jakedee Can you open a new issue for that?

from preact.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.