<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/rss/styles.xsl" type="text/xsl"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Krzysztof Żuraw</title><description>Blog about TypeScript, React and all things frontend</description><link>https://krzysztofzuraw.com/</link><item><title>July 2024 update</title><link>https://krzysztofzuraw.com/blog/2024/july-2024-update/</link><guid isPermaLink="true">https://krzysztofzuraw.com/blog/2024/july-2024-update/</guid><description>What happened it the last year</description><pubDate>Sun, 28 Jul 2024 14:43:07 GMT</pubDate><content:encoded>&lt;p&gt;Long time no see - I recently checked and it seems like the last blog post I wrote was about one year ago. I tried to come back to more regular writing schedule but having house is not easy task so I postponed it a couple of times and here we are - almost one year later.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What changed in this one year?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As I mentioned I bought a house in suburbs on Wrocław so almost all this year was connected with preparing it for living. It still amazes me how hard is to find good specialist for almost every stage of home renovating / preparing for use. Fortunately I managed to almost complete all of required work to have comfortable living (I wanted to avoid having renovation going on for next 10 years). That is why I think I can go back to writing more. At work I&apos;m currently mainly focused on backend part of Next.js applications - it is quite fun to works with server less environment so I think I will write more about this year.&lt;/p&gt;
&lt;p&gt;Let&apos;s get going and see you around 👋🏻&lt;/p&gt;
</content:encoded></item><item><title>How to link a local npm dependency with pnpm</title><link>https://krzysztofzuraw.com/blog/2023/link-a-local-npm-dep-pnpm/</link><guid isPermaLink="true">https://krzysztofzuraw.com/blog/2023/link-a-local-npm-dep-pnpm/</guid><description>2 step guide to installing your local npm dependency with pnpm</description><pubDate>Sun, 13 Aug 2023 11:48:05 GMT</pubDate><content:encoded>&lt;p&gt;I have learned how to correctly link a local npm dependency when using &lt;a href=&quot;https://pnpm.io/&quot;&gt;pnpm&lt;/a&gt;. Here is the process:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Execute &lt;code&gt;pnpm install ./your-library.tgz&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Include the following code in your &lt;code&gt;package.json&lt;/code&gt; file:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;{
  &quot;pnpm&quot;: {
    &quot;overrides&quot;: {
      &quot;your-library&quot;: &quot;file:./your-library.version.tgz&quot;
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your dependency should now be properly linked!&lt;/p&gt;
</content:encoded></item><item><title>How you properly test your React hook methods</title><link>https://krzysztofzuraw.com/blog/2023/test-react-hooks-methods/</link><guid isPermaLink="true">https://krzysztofzuraw.com/blog/2023/test-react-hooks-methods/</guid><description>You need to wrap your hooks methods in the `act` while testing</description><pubDate>Sun, 06 Aug 2023 11:19:11 GMT</pubDate><content:encoded>&lt;p&gt;If you are using &lt;a href=&quot;https://react-hooks-testing-library.com&quot;&gt;React Hooks testing library&lt;/a&gt; to test your hooks remember to wrap hooks methods in the &lt;a href=&quot;https://react-hooks-testing-library.com/reference/api#act&quot;&gt;&lt;code&gt;act&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For example, if you try to run the test below:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import { renderHook } from &quot;@testing-library/react-hooks&quot;;

test(&quot;test login&quot;, () =&amp;gt; {
  const { result } = renderHook(() =&amp;gt; useAuth());

  result.login();

  expect(result.user).toEqual({ token: &quot;token&quot;, user: &quot;Tom Smith&quot; });
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will get this error message:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Warning: An update to TestComponent inside a test was not wrapped in act(...).

When testing, code that causes React state updates should be wrapped into act(...):

act(() =&amp;gt; {
  /* fire events that update state */
});
/* assert on the output */

This ensures that you&apos;re testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
    at TestComponent ()
    at Suspense
    at ErrorBoundary ()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To fix this you need to wrap the &lt;code&gt;result.login&lt;/code&gt; call with the &lt;code&gt;act&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-import { renderHook } from &quot;@testing-library/react-hooks&quot;;
+import { renderHook, act } from &quot;@testing-library/react-hooks&quot;;

test(&quot;test login&quot;, () =&amp;gt; {
  const { result } = renderHook(() =&amp;gt; useAuth());

- result.login();
+ act(() =&amp;gt; {
+     result.login();
+ });

  expect(result.user).toEqual({ token: &quot;token&quot;, user: &quot;Tom Smith&quot; });
});
&lt;/code&gt;&lt;/pre&gt;
</content:encoded></item></channel></rss>