Setting variables
To create dynamic components using variable functions, typically follow the following procedure:
- Create (set) variables.
- After adding an action to update the variables,
- Make elements that are displayed differently depending on the variable.
The article below explains how to set basic variables. If you want to learn the functions through practice with the prepared tutorial, please proceed with the tutorial through the "Tutorial" link at the bottom of the page.
To create a variable, select the block you want to set the variable with and click Set variable in the Block menu.
In the variable window, click the + button and choose one of the following three options.
Import from the app (app variable)
Variables imported from the app contain special values provided by the app. For example, in the case of the Baedal Minjok app, it provides user information and device information are provided.
- Variable Name: Specifies the name of the variable to store the value imported from the app. (No spaces or special characters allowed)
- Select data: Click this field to see a list of apps available.
The values provided by each app, such as Baemin and Kaleidoscope, may be different. You must consider the environment in which a website made of mandao runs. For example, pages created using the Baemin app variable may not work properly within the kaleidoscope app.
Import from API (API variable)
When the block is displayed on the screen, calls automatically-set API and sets the value received as a response to the variable.
- Variable Name: Specifies the name of the variable to store the value imported from the app. (No spaces or special characters allowed)
- Select API: Click this field to see a list of APIs available.
Use another variable as API request value
When setting API variables, **the variable set above **can be used as the request value.
![Use other variables for variables] (/img/user-guide/using-variables-in-other-variable.png)
Use API Call Action to call the API when you click on the block.
Create a new variable (custom variable)
A custom variable** that allows you to freely set or change any value initially.
- Name of variable: Specifies the name of the custom variable. (No spaces or special characters allowed)
- Variable Value (Select): Sets the initial value of the custom variable.
Custom variable application
You can configure the Mandao app that interacts with the user without the variables or API connection handed over by the app. Learn the functions of variables by creating a tab UI that shows different elements according to the user's click!
- [Tutorial: Creating a tab UI] (/docs/tutorials/building-a-tab-ui)