Hello, I'm Stanko, a software engineer in Belgrade, writing mostly about JavaScript and React.

JavaScript 'time ago' function


Snippet for a rather popular requirement. Formatting a date in a nice way, using infamous “time ago” function. This is the basic version which I adapt to fit a specific project. To keep it easily customizable to your needs, I haven’t packaged it up.

Just pass a date to it, and function will return one of the seven possible formats:

Read more

First talk in React series

This time we joined forces with our friends from IT Girls. They are promoting tech among women, and helping them start a career in it. Together, we are organizing a series of meetups and workshops about React.

Last night, my colleague Nemanja and myself had a pleasure to give the first talk in the series. We are planning to have one more meetup followed by a couple of workshops, and for a great finale, hackathon will be organized.

After yesterday’s introduction to React, we’ll continue with more in depth talks, including more code examples. To reserve your place, make sure you apply in time, by following IT Girls’ website and Facebook.

Due to large interest, we might repeat the first talk. Slides are available for download.

React Router v4 redirect decorator

React Router switched to component based routing starting with the version 4. Redirects are now done by rendering a Redirect component, Please note that you can use included withRouter decorator but it can cause update blocking and introduce side effects. This is small subset of it.

<Redirect to='/redirect-url-here' />

What I usually do is to keep redirectTo property in component’s state. To redirect, I set it to the URL I want to redirect to, and render Redirect at the start of the render method:

Read more

React ratio

Short one today.

I’m continuing to release small libraries. So let me present react-ratio, another small React component. You probably guessed what it does - creates element with the given aspect ratio.

Check the demo or grab the source code

"has-tabbed" aka "Should I release small libraries?"

I just released tiny library called has-tabbed. Again, it is a small piece of code I regularly copy from project to project. I always considered it too insignificant for releasing it as a standalone package.

When user presses tab key, it adds By default --tabbed is used, but it accepts custom class as parameter. to html element. Then, if user clicks anywhere on the page, it removes it. That’s why I though it is too small. But after giving it some thought, my answer to the question in the title is “YES”.

You should release small libraries no matter how small they are.

Read more