Component argumnets
Component Arguments with Examples
In Stratox, components can utilize various arguments to manage and manipulate data, handle events, and communicate across different parts of the application. Below is a detailed explanation of each argument type, along with quick examples to demonstrate their usage.
1. Props
Props are objects and data passed to views or components. They are isolated within the view instance, allowing for dynamic updates to specific parts of the page.
Example:
2. State
States are global but scoped to the active route and controller method. Updating a state refreshes the entire page and all nested components.
Example:
3. Dispatch
The dispatcher facilitates making requests (GET, POST, PUT, DELETE) and passing data between routers and controller methods.
Example:
4. Update
A shortcut for updating and refreshing a view dynamically.
Example:
5. HTTP
Access server-side data such as HTTP methods or status codes.
Example:
6. Request
Provides access to dispatched requests via request.get
and request.post
.
Example:
Note: To safeguard against XSS vulnerabilities, encapsulate potentially injectable data within double curly braces.
7. View
Represents the main view instance, which can handle events and update content.
Example:
By adding false in second argumnet in bind you will not update and refresh the view.
8. Context
Access the Stratox context library to manage settings or default values.
Example:
9. Services
Used to access framework functions or communicate externally.
Example:
By understanding and utilizing these arguments effectively, you can build robust and dynamic applications with Stratox. Each argument serves a specific purpose, enabling a modular and maintainable approach to component development.
Last updated