<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nils Sens</title>
    <description>The latest articles on DEV Community by Nils Sens (@neilsentence).</description>
    <link>https://dev.to/neilsentence</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F591130%2F9c1a2a73-075e-4652-a1db-54ec30e6bec4.jpeg</url>
      <title>DEV Community: Nils Sens</title>
      <link>https://dev.to/neilsentence</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/neilsentence"/>
    <language>en</language>
    <item>
      <title>React acting unpredictably</title>
      <dc:creator>Nils Sens</dc:creator>
      <pubDate>Fri, 05 Mar 2021 19:31:02 +0000</pubDate>
      <link>https://dev.to/neilsentence/react-acting-unpredictably-5hgf</link>
      <guid>https://dev.to/neilsentence/react-acting-unpredictably-5hgf</guid>
      <description>&lt;h3&gt;
  
  
  update: one bug down. i had two identical key props on menu items! those were the ones where react didn't completely re-render...
&lt;/h3&gt;

&lt;p&gt;I joined this community because the frustration level with React has reached the ceiling.&lt;/p&gt;

&lt;p&gt;The website I'm working on is a small artist page. &lt;/p&gt;

&lt;p&gt;Sorry, I can't make a minimum reproducible version of the bug. The whole project is here on GH (feel free to grab my physics HTML implementation [warning: matter's Runner doesn't yet shut down upon re-mount, so things fall faster on each menu load])&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/NeilSentence/galerie-sens"&gt;https://github.com/NeilSentence/galerie-sens&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The menu has a bunch of colorful falling blocks in the form of HTML elements that receive their positional data from matter.js.&lt;/p&gt;

&lt;p&gt;This menu can be opened by clicking on "menu", or by pressing the Escape key, implemented in a custom hook from src/components/utils/esckey.js.&lt;/p&gt;

&lt;p&gt;The latter comes with a crazy bug:&lt;/p&gt;

&lt;p&gt;1.1. When you use the EscKey function to open the menu, this only works from the home path (/) and the ones without images. But not from the gallery paths!&lt;br&gt;
1.2. Although each of the paths includes the menu,&lt;br&gt;
1.3. and the mouse click on menu also works (!)&lt;/p&gt;

&lt;p&gt;The next issue that I think is really strange is &lt;/p&gt;

&lt;p&gt;2.1 If I open any gallery section except "upcycling" &amp;amp; "oel &amp;amp; sand", and click on a painting (zoomed in view),&lt;br&gt;
2.1.1 and I menu nav to another section, it starts in zoomed out view (correctly)&lt;br&gt;
2.1.2 but if I switch between the abovementioned two, the zoomed in view remains open, only the content is replaced.&lt;br&gt;
2.2.3 Before, it even had an extra messed up zoom factor, but that was fixed by adding numbered "key"-attributes.&lt;/p&gt;

&lt;p&gt;3.1 If I navigate to another section, react remembers the previously loaded artwork info object's number, and upon nav, the new gallery section opens at the same image number, not with the first painting&lt;/p&gt;

&lt;p&gt;3.2 causing an error when the first gallery section has more images than the next,&lt;br&gt;
3.2.1 and you nav from a higher image obj number than the next has in total (undefined...).&lt;/p&gt;

&lt;p&gt;The zoomed in view (einzelbild.js) is a nested component inside bilderwand.js.&lt;/p&gt;

&lt;p&gt;I understand that React somehow decides when to re-render a component and when not, but I'm not sure, when and how.&lt;/p&gt;

&lt;p&gt;It's cool when things fail and always fail, but this is random.&lt;/p&gt;

&lt;p&gt;I've been trying to force re-render and I tried different ways of using state, to no avail.&lt;/p&gt;

&lt;p&gt;These bugs almost turn me off from React!&lt;/p&gt;

&lt;p&gt;Nothing is predictable or seemingly logically related... :/&lt;/p&gt;

&lt;p&gt;Do I need to study how React is built in order to use it?&lt;/p&gt;

</description>
      <category>react</category>
    </item>
  </channel>
</rss>
