lunes, 10 de febrero de 2020

Postgres, error in tutorial?

Yesterday, I got a help request, about PostgreSQL. Can't develop much about it as the question was really unclear and I had problems on my own.

Every time I tried to use psql, I'd get:

psql: FATAL:  database "cayalame" does not exist

And I thought I had a complete and reliable PostgreSQL installation. I checked the tutorial I used, here. And it detailed:

createdb cayalame_db

but I already had that database in the system. After checking if user valid and creating again the database, I chose to create the database with the requested name. And voilà, Postgres working for the user.

Just to keep in mind, not to blindly follow instructions.

miércoles, 5 de febrero de 2020

Something hard to see

This is an experience that happened yesterday, February 4th 2020 with an example in Dev.to: Introduction to State Machines in React

The exercise is interesting in itself. But, spent quite some time wondering why it didn't work for me. The problem wasn't the state machine (in Xstate) but the JSX and how I was dealing with it.

My solution to the small inconvenience
The last definition of the const is the exercise requirement. See how difficult is to distinguish the space after "navbar-menu". So I chose the first definition. It is a bit longer but easy to see.

Later I published this experience in Twitter and got a suggestions: clsx, just a simple utility to add spaces between classes. Not useful in my case, as it is only one line but for projects that involve changing classes or adding them it certainly will be useful.

martes, 4 de febrero de 2020

React: Playing with Functions and Classes

Have just found this. They certainly do the same, this is the result

Browser results
But the code can be quite different.
Using functions:
Using a function in React
See that we are declaring the function receives props, though at first sight one, we don't know the nature of them.

Using classes:
Using a class in React
For the class, we are not declaring it receives anything. Do I have to suppose this? May be there's a misunderstanding, and there is a proper way to declare props.