Expanding events from props #626
JayaKrishnaNamburu
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
At the moment, we have two different types of events. One is for
stateChangeandpropCall.stateChange
A state change event can be used to assign a event to an element that can modify the state. We can assign a event that effects state using
{ "events": { "click": [ { "type": "stateChange", "modifies": "active", "newState": "$toggle" } ] } }This generates
React
Vue
Angular
propCall
{ "events": { "click": [ { "type": "propCall", "calls": "handleClick" } ] } }propCallcalls the function from theprops. But, we assign adefaultValuewhile definingprops. In generated code the prop gets a default value of string. Let's look at he example of reactReact
From the example we can see when the
handleClickhas a defaultProp of string and not a valid function. It should be changed toExtending the props based events
When we pass events to a component, often we want to send some meta back to the callback with the event. Here are multiple things we can do with the propCall events.
So, the uidl for
eventscan e extended to{ "events": { "click": [ { "type": "propCall", "calls": "handleClick", "handler": true, "arguments": [ { "type": "static", "content": "Hello" }, { "type": "dynamic", "content": { "referenceType": "prop", "id": "name" } } ] } ] } }Beta Was this translation helpful? Give feedback.
All reactions