<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jesper Blad Jensen on Medium]]></title>
        <description><![CDATA[Stories by Jesper Blad Jensen on Medium]]></description>
        <link>https://medium.com/@jesperbjensen_14518?source=rss-d80320a4c2f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*bdIuI09yTL98pRG7.</url>
            <title>Stories by Jesper Blad Jensen on Medium</title>
            <link>https://medium.com/@jesperbjensen_14518?source=rss-d80320a4c2f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 22:18:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jesperbjensen_14518/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Journey into Deno Land]]></title>
            <link>https://medium.com/@jesperbjensen_14518/journey-into-deno-land-863a9db2000f?source=rss-d80320a4c2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/863a9db2000f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[deno]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Jesper Blad Jensen]]></dc:creator>
            <pubDate>Sat, 16 May 2020 17:47:24 GMT</pubDate>
            <atom:updated>2020-05-16T19:34:06.329Z</atom:updated>
            <content:encoded><![CDATA[<p>So I found out about the <a href="https://deno.land/">Deno</a> thing today. So Deno is like an alternative to NodeJS. It’s a JavaScript runtime. I’m sure they are better to sell it than me.</p><p>What sold me to try it for a day, was that it supports TypeScript out of the box — so it’s like server side TypeScript without any configuration. A perfect fit as I want to try out to build something with <a href="https://www.snowpack.dev/">Snowpack</a>, on the client side. Deno also takes away the big node_modules folder and has it’s own way of importing dependencies (Deno does not support NPM directly — but more about that below)</p><p>So this blog post is a set of things I found out by playing with Deno.</p><p>First of. Installing Deno is very easy. It’s just a executable that you download by copy-pasting a command into your terminal. Right after that you got your Deno command in the terminal.</p><p>After that you can just create a <em>index.ts</em> file and console.log something out — and execute it with <em>deno run index.ts</em></p><p>Super easy.</p><p>But as a Web Developer the first thing I want to do is to serve something over HTTP. So I turn to their http module:</p><pre>import { serve } from &quot;https://deno.land/std@0.50.0/http/server.ts&quot;; </pre><pre>const s = serve({ port: 8000 });<br>console.log(&quot;http://localhost:8000/&quot;);</pre><pre>let headers = new Headers();<br>headers.set(&quot;content-type&quot;, &quot;text/html&quot;); </pre><pre>for await (const req of s) {<br>  req.respond({<br>    headers,<br>    body: &quot;&lt;h1&gt;Hello&lt;/h1&gt;,<br>  });<br>}</pre><p>So thats nice. But I want more. I want to serve GraphQL.</p><p>And here comes the problem. There is no GraphQL Package for Deno. (as of this writing)</p><p>So the solution is to use a CDN called <a href="https://cdn.pika.dev/">cdn.pika.dev</a> — it is a CDN that transforms NPM packages into something that can be eaten by Deno. So we just write this:</p><pre>import {<br>  graphql,<br>  GraphQLSchema,<br>  GraphQLObjectType,<br>  GraphQLString,<br>} from “https://cdn.pika.dev/graphql@^15.0.0&quot;;</pre><p>Then you can use that and just follow the documentation — and before you know it — you can pipe the response from graphql out via Deno.</p><p>The next thing you need is a database. There you can use Dexecutor:</p><pre>import Dexecutor from &quot;https://deno.land/x/dexecutor/mod.ts&quot;</pre><pre>// Creating the query executor client<br>let dexecutor = new Dexecutor({<br>  client: &quot;sqlite3&quot;,<br>  connection: {<br>    filename: &quot;test.db&quot;<br>  }<br>});</pre><pre>// Opening the connection</pre><pre>await dexecutor.connect();<br>await dexecutor.execute(`<br>  CREATE TABLE IF NOT EXISTS contacts  (<br>    contact_id INTEGER PRIMARY KEY,<br>    first_name TEXT NOT NULL,<br>    last_name TEXT NOT NULL,<br>    email TEXT NOT NULL UNIQUE,<br>    phone TEXT NOT NULL UNIQUE<br>  );<br>`)</pre><p>But you also need proper support in your editor. So I installed the <em>axetroy.vscode-deno</em> extension into VSCode (I had trouble with the other plugins) — be sure to read the README as you need to turn it on in your workspace.</p><p>You also need a tool to auto-reload your Deno server. For that I used <a href="https://deno.land/x/denon/">denon</a> — I used this config file:</p><pre>// .denon.json<br>{<br>    &quot;files&quot;: [<br>        &quot;index.ts&quot;<br>    ],<br>    &quot;deno_args&quot;:[<br>        &quot;--allow-net&quot;,<br>        &quot;--allow-read&quot;,<br>        &quot;--allow-write&quot;<br>    ],<br>    &quot;extensions&quot;: [<br>        &quot;.ts&quot;<br>    ],<br>    &quot;watch&quot;: [<br>        &quot;.&quot;<br>    ]<br>}</pre><p>And after that I just run my stuff with the <em>denon </em>command without any arguments.</p><p>And there you have it. I’m pretty sure I got a lot of the bricks needed to actually make a server that can serve my new Snowpack experiment. (I’m not sure what I’m going to make yet)</p><p>Deno seams easy. It’s still very early days for that runtime (it just hit 1.0)— but I think it was fun to hack around in — and I hope to write more blog posts as time goes by.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=863a9db2000f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React tip: Create a little helper function to make input state management easier]]></title>
            <link>https://medium.com/@jesperbjensen_14518/react-tip-create-a-little-helper-function-to-make-input-state-management-easier-818beb0a50e2?source=rss-d80320a4c2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/818beb0a50e2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Jesper Blad Jensen]]></dc:creator>
            <pubDate>Sun, 18 Dec 2016 14:31:20 GMT</pubDate>
            <atom:updated>2016-12-18T14:31:45.372Z</atom:updated>
            <content:encoded><![CDATA[<p>If you have a React component where you have some input fields, and all you just want is to sync their value to a state variable, you can use this little trick to make it a bit easier to write:</p><pre>function createInputBinder(component) {<br>  return (name) =&gt; ({<br>    onChange: (e) =&gt; { component.setState({[name]: e.target.value})},<br>    value: component.state &amp;&amp; component.state[name]<br>  })<br>}</pre><pre>class TestComponent extends Component {<br>  constructor() {<br>    super();<br>    this.state = { name: &quot;&quot; }<br>  }<br>  <br>  render() {<br>    let inputBinder = createInputBinder(this);<br>    return (<br>      &lt;div&gt;<br>        &lt;input type=&quot;text&quot; {...inputBinder(&quot;name&quot;)} /&gt;<br>      &lt;/div&gt;<br>    )<br>  }<br>}</pre><p>We use the object spread operator to allow a function to return multiple attributes for our React component. The createInputBuilder function creates a new function that we save in the variable inputBuilder that we can then use to <em>bind</em> a input field to the state.</p><p>This is just a simple example to get you started, it does not support checkboxes for example.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=818beb0a50e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React tip: Use a form tag if you want to do something when the user presses enter]]></title>
            <link>https://medium.com/@jesperbjensen_14518/react-tip-use-a-form-tag-if-you-want-to-do-something-when-the-user-presses-enter-2540825e2313?source=rss-d80320a4c2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2540825e2313</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jesper Blad Jensen]]></dc:creator>
            <pubDate>Sun, 18 Dec 2016 14:02:13 GMT</pubDate>
            <atom:updated>2016-12-18T19:15:09.495Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s very normal in user interfaces that something should be submitted when the user presses enter. In the old days this was handled by the famous and infamous form tag.</p><p>While we normally don’t want a form tag to submit something to a server directly in React, we can still use it for it’s <em>enter-behavior:</em></p><pre>let myComponent = (props) =&gt; (<br>  &lt;form onSubmit={handleSubmit}&gt;<br>    &lt;input /&gt;<br>  &lt;/form&gt;<br>)</pre><pre>function handleSubmit(e) {<br>  e.preventDefault(); // Remmember to call preventDefault<br>  console.log(&quot;Enter pressed&quot;); <br>}</pre><p>As an added benefit your mobile users will get a special submit button directly on their on-screen keyboard (at least on iOS)</p><p>I think this is a way simpler way, than listening to the key events and checking if the key that is pressed is the enter key.</p><p><strong>Update</strong>: Thomas B. Homburg (<a href="https://mobile.twitter.com/homborg">@homborg</a>) was nice to point out that if you have more than one input in your form tag, you need to add a button for the enter functionality to work. This is not a React specific thing. Also take note that the button tag changes from defaulting to type <em>button</em> to type <em>submit</em> when inside a form tag. Generally it’s always a good idea, is possible, to have a button visible as an alternative to pressing enter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2540825e2313" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add typings to Visual Studio Code to get better autocomplete / intellisense in your JavaScript code]]></title>
            <link>https://medium.com/@jesperbjensen_14518/add-typings-to-visual-studio-code-to-get-better-autocomplete-intellisense-in-your-javascript-code-8ebd1cf5ae7c?source=rss-d80320a4c2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ebd1cf5ae7c</guid>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jesper Blad Jensen]]></dc:creator>
            <pubDate>Sun, 18 Dec 2016 13:51:10 GMT</pubDate>
            <atom:updated>2016-12-18T13:53:29.446Z</atom:updated>
            <content:encoded><![CDATA[<p>One nice feature of <a href="https://code.visualstudio.com/">Visual Studio Code</a> is the ability to use the information from TypeScript Definition files to power your autocomplete of Visual Studio Code. When theese packages are installed it will help you explore what functions that can be called when you write <em>dot</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*-PEzHqLt9luwhbEp72C0UA.png" /><figcaption>This is an example of how the autocomplete will look like</figcaption></figure><p>What you need to do is just to install the type npm packages that matches the library that you are importing, for example if you use react:</p><pre>npm install @types/react --save-dev</pre><p>In general the packages is just @types/packagename.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ebd1cf5ae7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest & Enzyme Cheatsheet]]></title>
            <link>https://medium.com/@jesperbjensen_14518/jest-enzyme-cheatsheet-e7c52d3f8af7?source=rss-d80320a4c2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7c52d3f8af7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Jesper Blad Jensen]]></dc:creator>
            <pubDate>Sun, 18 Dec 2016 13:40:03 GMT</pubDate>
            <atom:updated>2016-12-18T13:40:03.890Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post I will collect some tips to Jest &amp; Enzyme as I encounter them.</p><p>Simulate and test an event:</p><pre>const onChangeHandle = jest.fn() // Create a mock</pre><pre>const result = shallow(&lt;input onChange={onChangeHandle} /&gt;)<br>const eventArgs = { target: { value: ‘test’ }};<br>result.first().simulate(“change”, eventArgs);</pre><pre>// Expect the mock to be called with the currect arguments<br>expect(onChangeHandle).toBeCalledWith(eventArgs);</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7c52d3f8af7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>