Skip to main content

Using a parent components properly value and a variable within a child component


Harrison_Adam_Cole

If component properties could be assigned as variables to components within them in the same way variables can be it would reduce the amount of variants of parent components.

Example: I have a table in which each each row is a component with variants ranging from 3 columns to 10 columns as well as a header component constructed in the same way and a total row that is fixed. The rows are then placed within a component, where you can select the number of rows, one to eight. In this set up the parent component has 64 variants. If the parent component could have a property for a number of columns that could be used as a variable by a nested component it would mean that the parent only needs 8 variants. It would also make it easier to change the properties of components in another component where they should match, say you have a status box component that contains a number of child components, one is an icon that can either be a thumbs up or a thumbs down, ad another component that is a coloured accent line that can be either green or red, you set the property of both as β€˜is bad’ with a Boolean, mirror that on the parent and then with the variants of the children within pass that true false as a variable.
Would this help you:

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings