In React, we pass elements to a component by simply passing elements to a prop. Here’s an example:

It works! But what if we could improve our semantics? What if we could imitate how Vue does this?

Enter Vue slots. Vue slots are a convenient way to distribute content…

If it looks stupid but works, it ain’t stupid.

If you haven’t read about render props before, check out:

Problem

You have a lot of sorting presets (Chronological, reverse-chronological, alphabetical, et al).

For performance reasons, you want to store the filtered array into your state instead of doing the filtering inside…

If you’re fairly new to building UIs, specifically with React, deciding the data structure for the states of each item in a collection can be quite tricky. But as you progress and learn techniques, especially this one, hopefully this kind of task becomes less terrifying.

Scenario

Here’s an example of the…

When using Eloquent’s scoped queries, use the provided as the first argument.

Wrong

class Post extends Eloquent {
scopeRecent() {
$weekago = //;
return $this->where(‘created_at’, ‘>=’, $weekago);
}
}

This will work but not produce correct results.

Correct

class Post extends Eloquent {
scopeRecent($query) {
$weekago = //;
return $query->where(‘created_at’, ‘>=’, $weekago);
}
}

I rarely use the docs since I’ve been using Laravel for years now. But this — this has bitten me a number of times.

Inevitably, the typical (but reckless) setup in the becoming-common API-centric development is having the backend and frontend work at the same time.

However, because the frontend relies on the backend, slight delays from the backend can cause detrimental impact to the team’s productivity and deadlines.

Use case

Like most methodologies, apply this…

Currently, Envoyer does not yet have any option to skip composer install. This was initially a downer because I’m deploying a Laravel application running on Docker.

But it was actually quite a simple feat to accomplish through Deployment Hooks.

How-To

In the Install Composer Dependencies action, add a pre-hook that moves composer.json outside the release folder:

cd {{release}}
mv composer.json /tmp

And a post-hook that moves composer.json back to the release folder:

cd {{release}}
mv /tmp/composer.json ./

Deploy your application afterwards.

Explanation

Basically, Envoyer runs the composer installation in the mentioned action (as the name dictates) if composer.json is found in the release directory.

Kier Borromeo

Code monkey, mostly JS.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store