Comments (6)
We can create a new interface and move there the functionality from ReactAdapterComponent
, and then keep the ReactAdapterComponent
abstract class as a shortcut for simple cases that implements this new interface and extends Component
. What do you think?
Also, maybe a separate docs issue - we need an example of how to wrap a React component as a Flow field, e.g. to be able to use it with the Binder on a form.
from flow.
As long as we can have an interface to avoid the boilerplate, I'm not against a abstract class in addition. I don't know if that will make things easier.
With ReactAdapterComponent
class:
@JsModule("./react-component.tsx")
@Tag("react-component")
public class ReactMonthYearField
extends ReactAdapterComponent {
With the interface:
@JsModule("./react-component.tsx")
@Tag("react-component")
public class ReactMonthYearField
extends Component
implements IReactAdapter {
Also, maybe a separate docs issue - we need an example of how to wrap a React component as a Flow field, e.g. to be able to use it with the Binder on a form.
Or a blog post, it depends a bit of what you want to implement (HasTooltip, HasLabel, HasHelper, HasValidation,...), that can be tough.
And that could be done for Lit or a webcomponent also :).
But at least in the repository I linked (https://github.com/jcgueriaud1/vaadin-react-field/), you have an example for both React and Lit.
from flow.
I don't think an interface is the right option since interfaces define the public API of a class and you wouldn't want to make methods like setState
part of the API that users of your component would see.
Instead, there might be an opportunity for a "connector" that you can use from your component. A simple example could thus look like this:
@Tag("some-tag")
@JsModule("./someModule")
public class MyComponent extends SomeOtherComponent {
private final ReactComponentConnector connector = new ReactComponentConnector(this);
public void setValue(String value) {
connector.setState("value", value);
}
}
from flow.
I've just noticed that I'm not using the interface at all, since I'm using getElement().setProperty("invalid", invalid);
and not setState("invalid",invalid);
I think the connector could handle the other case and leave everything protected. (I'm not sure if everything can be handled with properties)
from flow.
The implementation of ReactAdapterComponent
is basically just some helpers around Element::setPropertyJson
, Element::getPropertyRaw
and Element::addPropertyChangeListener
. All of the actual magic is handled by Flow and/or the client-side base class for the custom element.
from flow.
thumbs up for the connector idea This would allow the usage of AbstractSinglePropertyField
and other important classes without cluttering the public interface.
from flow.
Related Issues (20)
- [Placeholder] PostponeUpdateIT::postpone_cancelResetsUrlOnBack HOT 1
- [Placeholder] NavigationTriggerIT::testNavigationTriggers fails
- Hilla app with @PWA annotation fails when running as native compiled image on macOS HOT 18
- Bun not being recognized on Windows HOT 2
- IndexOutOfBoundsException on UI#push() call HOT 2
- Browser window is opened again on redeploy after a while HOT 6
- Flow app might redirect to /login page when code is compiling in the background. HOT 8
- Additional navigation events caused by firing popstate events HOT 2
- Improve the client-side exception handling for "Invalid JSON from server" errors HOT 2
- Missing translation files causes an error with translate HOT 1
- [PiT 24.4.0 RC1] business-app-starter-flow is broken with V24.4.0.rc1
- PiT 24.4: when migrating a hilla project from `2.5.5` to `24.4.0.rc1` old stuff in `generated` folder fail compilation HOT 1
- Include `.scss` and `.sass` in `stats.json` hashes HOT 3
- Filter classpath scanning for `FrontendDependencies` HOT 2
- PiT 24.4: Regression in navigation events HOT 1
- Menu Icons are not shown in production mode HOT 2
- Two times invocation of the com.vaadin.flow.router.HasUrlParameter#setParameter method in Vaadin Flow 24.4.0.rc1 HOT 4
- Support `filterClasspath` in Maven plugin, similar to Gradle plugin
- Consider switching from Reflections to a maintained library
- Client-side JS error when showing a Dialog with certain types of components on it HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flow.