<?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 Martin Brochhaus on Medium]]></title>
        <description><![CDATA[Stories by Martin Brochhaus on Medium]]></description>
        <link>https://medium.com/@mbrochh?source=rss-bfc1a046c8e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*j0Z6XJVqZTrrynOA.jpg</url>
            <title>Stories by Martin Brochhaus on Medium</title>
            <link>https://medium.com/@mbrochh?source=rss-bfc1a046c8e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 09:21:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mbrochh/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[Migrating from glamorous to emotion]]></title>
            <link>https://medium.com/bitlab-studio/migrating-from-glamorous-to-emotion-64027cbef973?source=rss-bfc1a046c8e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/64027cbef973</guid>
            <category><![CDATA[glamorous]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[razzle]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Martin Brochhaus]]></dc:creator>
            <pubDate>Mon, 04 Mar 2019 08:17:32 GMT</pubDate>
            <atom:updated>2019-03-07T12:58:05.344Z</atom:updated>
            <content:encoded><![CDATA[<p>When our clients give us total freedom to decide on the full stack, we love to build the frontend with ReactJS and kickstart the repository with <a href="https://github.com/jaredpalmer/razzle">Razzle</a>.</p><p>Razzle is great because it is almost like create-react-app (CRA) but it is properly setup for Server Side Rendering (SSR) and has nice ways to add custom plugins without needing to eject.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eszy_Vwf8-cSYAKW" /><figcaption>Photo by <a href="https://unsplash.com/@maxcodes?utm_source=medium&amp;utm_medium=referral">Max Nelson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We are also big fans of CSS in JS, so in the past two years we built all our projects with <a href="https://glamorous.rocks/">Glamorous</a>. As we all know the JS ecosystem evolves with breakneck speed, so in May 2018 it became clear that <a href="https://github.com/paypal/glamorous/issues/419">Glamorous would be discontinued in favour of emotion</a>.</p><p>Recently, we have upgraded a large codebase from glamorous to emotion and just in case that others might find themselves in a similar situation, we would like to document our process in this blog post.</p><blockquote>In case you are already worrying: It’s really not so bad, you can definitely get this done for your own codebase, too!</blockquote><h3>Let’s get this done!</h3><p>First, we want to install emotion:</p><pre>yarn add @emotion/core<br>yarn add @emotion/styled<br>yarn add emotion-theming</pre><p>Now we can replace all ThemeProvider imports. This one is really easy:</p><pre>// old:<br>import { ThemeProvider } from &#39;glamorous&#39;<br>// new:<br>import { ThemeProvider } from &#39;emotion-theming&#39;</pre><p>Next we can change all glamorous imports and all styled components. This will probably be the most time-consuming part. In theory, you might be able to get this done with a project-wide search and replace:</p><pre>// replace this:<br>// import glamorous from &#39;glamorous&#39;<br>// with this:<br>import styled from &#39;@emotion/styled&#39;<br><br>// replace this:<br>// const Foobar = glamorous.div({...})<br>// with this:<br>const Foobar = styled.div({...})</pre><p>If you intend to use TypeScript anytime soon (which we can highly recommend), we would suggest to actually change your styled components to look like below. That syntax will allow you to add the type of the expected props for your styled component:</p><pre>const Foobar = styled(&#39;div&#39;)({...})</pre><pre>// later, when you use Typescript, you can do this:</pre><pre>interface FoobarProps {<br>  isDisabled?: boolean<br>}<br>const Foobar = styled(&#39;div&#39;)&lt;FoobarProps&gt;({...})</pre><p>The next step is not really necessary, but if you want the full power of emotion, you would want to replace all your style={} props with css={}. We got this working like shown below. In any file where you want to use the css prop, you need to add the /** @jsx jsx */ comment at the top of the file:</p><pre>// add this:<br>/** @jsx jsx */<br>import { jsx } from &#39;@emotion/core&#39;</pre><pre>// remove the React import<br>// HINT: when removing React import, <br>// make sure you don&#39;t use `extends React.Component`<br>// at the class definition<br>import { Component } from &#39;react&#39;<br><br>class Foobar extends Component {<br>  render() {<br>    // replace `style` with `css`<br>    return (<br>      &lt;div css={...}&gt;Foo&lt;/div&gt;<br>    )<br>  }<br>}</pre><p>NOTE: Sometimes we got a strange jsx is not defined error even though jsx was clearly being imported at the top of the file. We worked around this (with an ugly hack) by adding this after our imports:</p><pre>// tslint:disable-next-line:no-unused-expression<br>jsx</pre><p>We had one style in our codebase that emotion did not like. Thankfully, the error message stated very clearly how it can be fixed. If you ever use the content style, you will need to add double-quotes:</p><pre>const Foobar = styled.p = props =&gt; ({<br>  &#39;::after&#39;: {</pre><pre>    // old:<br>    // content: props.isMandatory ? &#39; *&#39; : undefined,</pre><pre>    // new:<br>    content: props.isMandatory ? &#39;&quot; *&quot;&#39; : &quot;&quot;,<br>  },<br>}))</pre><p>Furthermore, emotion raises a deprecation warning for the usage of innerRef. Instead we are supposed to just use ref. If your codebase is a bit older, this might be a good opportunity to refactor your code to also use <a href="https://reactjs.org/docs/refs-and-the-dom.html#creating-refs">React.createRef()</a> (not shown in this example):</p><pre>// old:<br>// &lt;SomeStyledComponent innerRef={ref =&gt; (this.container = ref)} /&gt;</pre><pre>// new:<br>&lt;SomeStyledComponent ref={ref =&gt; (this.container = ref)} /&gt;</pre><p>The final step might not apply to you if you don’t use Razzle. If you do, you can now simplify your server.js quite a bit. It’s quite amazing how much simpler the SSR setup is with emotion compared to glamorous. This last code-block might look quite different in your code-base, but hopefully it gives you an idea about what code will no longer be needed:</p><pre>// delete this:<br>// import { renderStatic } from &#39;glamor/server&#39;<br><br>...<br><br>// change this:<br>// const glamorResult = renderStatic(() =&gt; renderToString(app))<br><br>// to this:<br>const html = renderToString(app)<br><br>...<br><br>// delete this:<br>// &lt;style&gt;${glamorResult.css}&lt;/style&gt;<br><br>...<br><br>// change this:<br>// &lt;div id=&quot;root&quot;&gt;${glamorResult.html}&lt;/div&gt;<br><br>// to this:<br>&lt;div id=&quot;root&quot;&gt;${html}&lt;/div&gt;</pre><p>To finish the job, you might want to remove glamorous and glamor from package.json and yarn.lock, delete node_modules folder and run yarn install.</p><p>Hopefully we didn&#39;t forget to document anything here and everything still works.</p><p>Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64027cbef973" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bitlab-studio/migrating-from-glamorous-to-emotion-64027cbef973">Migrating from glamorous to emotion</a> was originally published in <a href="https://medium.com/bitlab-studio">Bitlab Studio</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Something needs to change]]></title>
            <link>https://medium.com/@mbrochh/something-needs-to-change-462cfe885bbd?source=rss-bfc1a046c8e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/462cfe885bbd</guid>
            <category><![CDATA[health]]></category>
            <category><![CDATA[food]]></category>
            <category><![CDATA[refined-sugar]]></category>
            <dc:creator><![CDATA[Martin Brochhaus]]></dc:creator>
            <pubDate>Mon, 10 Oct 2016 15:24:55 GMT</pubDate>
            <atom:updated>2016-10-11T01:53:14.301Z</atom:updated>
            <content:encoded><![CDATA[<h3>Something Needs to Change</h3><h4>Refined sugar is killing me softly…</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LrNEm9wufdy4Co2qv40XHg.jpeg" /><figcaption>Image source: <a href="https://www.pexels.com/photo/cafe-book-doughnut-chocolate-30185/">https://www.pexels.com/photo/cafe-book-doughnut-chocolate-30185/</a></figcaption></figure><p>I don’t expect anyone to read this but I’m publishing it anyways because:</p><ol><li>It will probably motivate me to keep going</li><li>I wanted to try out Medium for years already</li></ol><p>In June I got a little flu — in fact, pretty much everyone in Singapore got that flu, but I was a bit more unlucky and it turned into a serious bronchitis that lasted somewhere between eight or ten weeks.</p><p>Until just a few weeks ago, I wouldn’t be able to laugh about something because that would trigger a cough that stung in my thoat pretty badly. Even to this very day, I still feel like my lungs are completely clogged up with slime and as a result I constantly have to clear my throat throughout the day.</p><p>So I feel like I have been permanently sick for almost four and a half months now. I feel like I have a become a shadow of myself. I haven’t done any sports during this whole period. I haven’t visit any tech meetups. I haven’t mentored anyone, not even our new developers at work. I have been eating way too much junk food and I have been playing way too much PS4 because “hey, I’m sick, after all, what else can I do?”.</p><p>Today, I saw <a href="https://twitter.com/Pocket/status/785473205741953025">this tweet</a> and it opened my eyes, once again. I have been gobbling up refined sugar like crazy — one cappucino in the morning,a coke light for lunch, maybe a flat white to survive the afternoon crash. Muffins? Any time! Noodles? How do you even live without noodldes?! MOS burger for dinner? Sure! And you know what that means: a litre of sweet lemon tea and tons of sweet sweet tomato ketchup. I even started eating cereals with milk for breakfast, something I have never done in the six years that I have spent in Singapore, so far.</p><p>All in all, I have been eating shit in the last four months and as a result I feel as unhealthy, weak, depressed, unmotivated and lethargic as never before. I can’t even get out of the bed before 8am. I used to wake up naturally at 5:30am.</p><p>So, inspired by said tweet, I will try to eliminate all refined sugar from my died as of right now and I will keep a little journal here on medium, because as I said:</p><ol><li>It will probably motivate me to keep going</li><li>I wanted to try out Medium for years already</li></ol><p>I don’t expect anyone to read this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=462cfe885bbd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>