livewire/livewire · error · Exception

Invalid Livewire child tag name. Tag names must only contain

Error message

Invalid Livewire child tag name. Tag names must only contain letters, numbers, and hyphens.

What it means

Error "Invalid Livewire child tag name. Tag names must only contain letters, numbers, and hyphens." thrown in livewire/livewire.

Source

Thrown at src/Features/SupportNestingComponents/SupportNestingComponents.php:102

    function getChildren() { return $this->storeGet('children', []); }
    function setChild($key, $tag, $id) { $this->storePush('children', [$tag, $id], $key); }

    static function setParentChild($parent, $key, $tag, $id) { store($parent)->push('children', [$tag, $id], $key); }
    static function setPreviouslyRenderedChildren($component, $children) { store($component)->set('previousChildren', $children); }
    static function hasPreviouslyRenderedChild($parent, $key) {
        return array_key_exists($key, store($parent)->get('previousChildren', []));
    }

    static function getPreviouslyRenderedChild($parent, $key)
    {
        $child = store($parent)->get('previousChildren')[$key];

        [$tag, $childId] = $child;

        // Validate tag name - only allow valid HTML tag characters (letters, numbers, hyphens)
        // Must start with a letter to be a valid HTML tag
        if (! preg_match('/^[a-zA-Z][a-zA-Z0-9\-]*$/', $tag)) {
            throw new \Exception('Invalid Livewire child tag name. Tag names must only contain letters, numbers, and hyphens.');
        }

        // Validate child ID format - only allow alphanumeric and hyphens
        if (! preg_match('/^[a-zA-Z0-9\-]+$/', $childId)) {
            throw new \Exception('Invalid Livewire child component ID format.');
        }

        return $child;
    }

    function keepRenderedChildren()
    {
        $this->storeSet('children', $this->storeGet('previousChildren'));
    }

    static function setParametersToMatchingProperties($component, $params)
    {
        // Assign all public component properties that have matching parameters.

View on GitHub (pinned to 1a3fde34c5)

When it happens

Trigger: Thrown at src/Features/SupportNestingComponents/SupportNestingComponents.php:102 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of livewire/livewire@1a3fde34c5 (2026-08-17). Data as JSON: /api/errors/46322c3561c5fd3e. Report an issue: GitHub.