You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever this value is used, it will be replaced with the expression props.title or this.props.title or however the framework references a prop value.
Problem
Sometimes the props or states are more than just simple values that need to be show on the screen or passed as some arguments. A relevant example is a state value representing the activeTab.
activeTab can be: 0, 1, 2, 3, etc. but I would like to be able to set an attribute to true when the activeTab is equal to a certain value.
The code that would set the data-active value to true when the third tab is selected would be:
The dyamic node should have some additional constructs that allows you to write a transformation / expression on that particular value. A few ideas / proposals below:
Context
When using a dynamic node, we reference the exact value of that prop/state/local var. Like in this example:
Whenever this value is used, it will be replaced with the expression
props.title
orthis.props.title
or however the framework references a prop value.Problem
Sometimes the
props
orstates
are more than just simple values that need to be show on the screen or passed as some arguments. A relevant example is a state value representing theactiveTab
.activeTab
can be: 0, 1, 2, 3, etc. but I would like to be able to set an attribute totrue
when the activeTab is equal to a certain value.The code that would set the
data-active
value totrue
when the third tab is selected would be:However, we can only set an attribute to an exact dynamic value, not to an expression using that dynamic value.
Solution
The dyamic node should have some additional constructs that allows you to write a transformation / expression on that particular value. A few ideas / proposals below:
Expression
Here we produce
{ state.activeTab === 2 }
Transformation
Here we produce
{ state.activeTab + 3 }
Member Expression
Here we would produce
{ state.products.length }
Function Expression
Here we would produce
{ parseInt(state.activeTab, 10) }
The text was updated successfully, but these errors were encountered: