React doesn't mean every tiny thing is a component

So Heading

As I set out to learn React as the latest language / library / tool to be added to my belt, there was an unwritten rule in most tutorials that everything should be component made up of components made up of components. This is false.

One of the things that ended up convincing me to go with React over other perfectly good choices like Angular was that React is pretty great at co-existing with non-React.

Remember that time when we had a block quote?

Yes, there is at least one component, usually called App, that is where your React app lives. But you could literally cram your entire page into that component and it would work fine.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace OpusV4m;

use Utility;

class Shortcodes {

    public function __construct() {
        add_shortcode('artistDashboard', [$this, 'loadArtistDashboard']);
    }

    public function loadArtistDashboard($atts, $content = null) {

        if (!is_user_logged_in()) {
            return '<div id="v4m-artist-dashboard">You must be logged in to use the Artist Dashboard.</div>';
        }

        wp_enqueue_script('v4m-react-1', plugins_url('../dashboard/js/runtime~main.js', __FILE__), [], System::VERSION);
        wp_enqueue_script('v4m-react-2', plugins_url('../dashboard/js/main.chunk.js', __FILE__), [], System::VERSION);
        wp_enqueue_script('v4m-react-3', plugins_url('../dashboard/js/2.chunk.js', __FILE__), [], System::VERSION);
        wp_localize_script('v4m-react-2', 'wpApiSettings', [
            'nonce' => wp_create_nonce('wp_rest'),
            'apiUrl' => get_rest_url(null, '/v4m/v1/')
        ]);
        // Commented out so that the WP app can load styles
        // These are strictly from index.css in the React app, which is there to allow the standalone app to appear
        // like where it will eventually be delivered during development
        wp_enqueue_style('v4m-react-1', plugins_url('../dashboard/css/main.chunk.css', __FILE__), [], System::VERSION);
        wp_enqueue_style('v4m-react-2', plugins_url('../dashboard/css/2.chunk.css', __FILE__), [], System::VERSION);

        return '<div id="v4m-artist-dashboard"></div>';
    }

}

Time for Zombies

Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis. Summus brains sit​​, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris. Hi mindless mortuis soulless creaturas, imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium.

This is big and amazing

Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis. Summus brains sit​​, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris. Hi mindless mortuis soulless creaturas, imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium.

Let's get started

  • This field is for validation purposes and should be left unchanged.