Skip to content

Feat: add loadComponentScript method - #18601

Merged
mshabarov merged 1 commit into
mainfrom
issues/18401-add-load-method
Feb 2, 2024
Merged

mshabarov merged 1 commit into
mainfrom
issues/18401-add-load-method

Conversation

@caalador

@caalador caalador commented Feb 2, 2024

Copy link
Copy Markdown
Contributor

Add the loadComponentScript method
to Flow.tsx to be used when
WebComponents are loaded for
Hilla views.

part of #18401

Add the loadComponentScript method
to Flow.tsx to be used when
WebComponents are loaded for
Hilla views.
@sonarqubecloud

sonarqubecloud Bot commented Feb 2, 2024

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@github-actions

github-actions Bot commented Feb 2, 2024

Copy link
Copy Markdown
Contributor

Test Results

1 092 files  ± 0  1 092 suites  ±0   1h 19m 59s ⏱️ - 1m 43s
6 836 tests ± 0  6 790 ✅ ± 0  46 💤 ±0  0 ❌ ±0 
7 190 runs  +21  7 132 ✅ +21  58 💤 ±0  0 ❌ ±0 

Results for commit 6515b21. ± Comparison against base commit 5c7ba9e.

@mshabarov

Copy link
Copy Markdown
Contributor

Can we merge this function and React.createElement(LOGIN_COMPONENT);, so to have them both incapsulated in

function MyLoginView() {
    return /*create and load the component*/;
}

?

@caalador

caalador commented Feb 2, 2024

Copy link
Copy Markdown
Contributor Author

Yes we can have it as

import {VerticalLayout} from "@vaadin/react-components/VerticalLayout.js";
import React, {useEffect} from "react";
import { loadComponentScript } from "Frontend/generated/flow/Flow";

function MyLoginView() {
    const LOGIN_COMPONENT = "my-flow-component";
    loadComponentScript(LOGIN_COMPONENT);
    return React.createElement(LOGIN_COMPONENT);
}

export default function HillaView() {
    return (
        <>
            <VerticalLayout className={'centered-content'}>
                <h3>Hilla View</h3>
                <MyLoginView/>
            </VerticalLayout>
        </>
    );
}

@mshabarov

Copy link
Copy Markdown
Contributor

Ok, let's leave it as is, because React.createElement may have a more advanced usage (e.g. with attributes), so better to leave this part for developers.

@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 24.4.0.alpha3 and is also targeting the upcoming stable 24.4.0 version.

rodolforfq pushed a commit that referenced this pull request Feb 8, 2024
Add the loadComponentScript method
to Flow.tsx to be used when
WebComponents are loaded for
Hilla views.

part of #18401
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants