-
Anchor links pointing to a fragment fires History API's "popstate" event
posted in JavaScript on 2022-11-15 history popstate anchor javascript -
I hit an interesting "bug" while working on a SPA application. Clicking an anchor link that points to a fragment on the page fires the History API's
read morepopstate
event. This triggers some logic on my end, which was not my intent. I fixed that with a bit of JavaScript, and I had to share the snippet.
-
Using JavaScript module system for state management
posted in JavaScript on 2021-03-08 javascript module state management -
Hot topic last couple of years is state management. Especially in the front-end apps. There are lots of problems and lots of solutions. One thing thought is totally ignored in this context - the JavaScript module system. I'm very often reaching out to this approach and decided to share it here.
read more
-
React: 50 shades of state
posted in JavaScript on 2020-07-21 react state management form components button viewmore compound state component theme onchange application state feature state data client text span const -
We all know that one of the most challenging task in software development is state management. This is especially true for the JavaScript world. There are thousands of articles on this topic and so I decided to write another one 😁. I wanted to share my current thoughts on the different state types. I found that answering "What lives where?" question is far more important than the actual state management. Which more or less is an implementation detail.
read more
-
Recreating Facebook's Recoil library
posted in JavaScript on 2020-07-12 recoil facebook state management mycoil facebook s recoil counter atoms atom component library formattedcountervalue selector key function javascript subscribers hook const return -
This weekend I decided to play with the new kid on the block - Facebook's Recoil library for managing state. I did the trivial counter example to see how it works. It's pretty simple idea so I wondered how much it takes to replicate its features. I found the exact answer - 70 lines of code. Obviously, my implementation didn't cover everything but it was fun so I decided to share my findings.
(A side note: I did not look at the code of Recoil. I didn't want to be bias on how to write my version.)
read more
-
Part 3: Riew - reactive view in patterns
posted in Riew on 2020-01-06 riew csp routine go javascript channels console log yield krasimir riew https github function state const -
In this article we will see some use cases of Riew. Those are patterns which I found repeating while using the library. There are other blog posts part of the same series and I will suggest checking at least this one so you get a basic understanding before jumping into the code snippets below.
read more
-
Rethinking the Redux API
posted in JavaScript on 2019-09-10 redux const state login username password authenticated action function reducer -
I really like Redux. I Love its ideas. The reducers for example - small pure functions that apply changes without side effects are nice way to model the mutations in the state. Redux also teaches us to use the one-direction data flow which makes our apps more predictable and stable. These two things fits well for what we are doing on the front-end - building user interfaces.
Of course there is nothing perfect and Redux as every other library has its own problems. In this article I want to explore some ideas for new APIs that will help solving the problems that I encounter. I’ll be happy to see your comments below.
read more
-
Jolly Roger - a 2KB micro-framework based on React hooks API
posted in JavaScript on 2019-04-20 time roger const state return function usestate yohoho action -
The hooks API is a wonderful idea. There are some slick patterns involved that push the React development to a more functional approach. I'm interested in trying that new API and decided to use it for my latest project. However, after a couple of days, it looked like I can't build my app only with hooks. I needed something else. And that's mainly because each hook works on a local component level. I can't really transfer state or exchange reducers between the components. That's why I created Jolly Roger. It has similar helpers but works on a global app level.
read more
-
forEach or not to forEach
posted in JavaScript on 2019-04-12 array foreach item component update react iteration position remove state -
I had an interesting bug in my React application. It happened that the problem was in the fact that I was using
forEach
instead offor
.The bug that I was encounter was
read more
-
React hooks: changing the mindset
posted in JavaScript on 2018-10-31 react function hooks count counter return useeffect state const usestate -
If you use React you probably know about the so called hooks. They were officially announced at this year's ReactConf by Sophie Alpert and Dan Abramov. Their presentation could be seen here. I, same as many others got intrigued by this new feature. A little bit confused by if I like them or not but kind of excited. This article pretty much sums up my thinkings around React hooks and aims to give a balanced opinion.
read more
-
My take on Redux architecture
posted in JavaScript on 2018-04-06 state action redux const visible store function return counter type -
Redux is a library that acts as a state container and helps managing your application data flow. It was introduced back in 2015 at ReactEurope conference (video) by Dan Abramov. It is similar to Flux architecture and has a lot in common with it. In this section we will create a small counter app using Redux alongside React.
read more
-
Debugging your front-end like it's 2019
posted in JavaScript on 2018-01-20 kuker step answer redux state events robot event result -
(If you are lazy jump to this section to learn what is this article all about.)
Remember The Island movie from 2005. I watched it again these days and I realized that the old sci-fi titles start with something really interesting. It is funny how they create a world of flying vehicles and say something like "The year is 2019 …". Well, we are 2018 and the public transport is still on the ground. We still can't clone people (I hope so) or travel in a giant spaceship which looks like a fully-functional city.
read more
-
Markup as function
posted in JavaScript on 2017-12-01 ischristmas user state function children component props greeting redux userdataprovider jsx -
If you are writing React applications you probably know about higher order components or render props (which by the way I think is kind of a form of higher order component pattern). In both cases we have a component that encapsulates logic and passes props down to children. Recently at work we came to the idea that we may push this further and represent some functionalities which are out of React in the same fashion - with a single tag in our components tree.
read more
-
Getting from Redux to a state machine
posted in JavaScript on 2017-11-10 state error machine const user redux credentials login submit stent -
This article is about Stent - a Redux-liked library that creates and manages state machines. Stent implements some of the Redux’s core ideas and in fact looks a lot like it. At the end of this post we will see that both libraries have a lot in common. Stent is just using state machines under the hood and eliminates some of the boilerplate that comes with Redux’s workflow.
read more
-
You are managing state? Think twice.
posted in JavaScript on 2017-10-27 state input false state machine isinprogress request isloggedin submit states message -
Recently I started questioning the state management in React applications. I’ve made some really interesting conclusions and in this article I’ll show you that what we call a state management may not be exactly about managing state.
read more
-
NADCAST.09 с Радо Станков
posted in NADCAST on 2017-10-23 link react https facebook license nadcast graphql http state facebook event link -
Епизод 9 на NADCAST е с Радо Станков. Основно си поговорихме за React и нашумелите около библиотеката теми. Приятно слушане :)
read more
-
The powerful higher-order component pattern
posted in JavaScript on 2017-06-10 component function props react const job dependencies h1 return state -
There are lots of things which I like in React. Mostly the fact that it teaches interesting patterns. One of my favorites ones is higher-order component. In this article we’ll do a couple of experiments and will see how powerful this approach could be.
read more
-
JavaScript's reduce could be really helpful
posted in JavaScript on 2015-12-25 testcase true patterns state reduce current cases expected return array test -
I love using functions like
read moremap
,filter
orreduce
. They are an important part of my arsenal and I simply can’t stop using them. Today I had to solve an interesting problem and I ended up usingreduce
.