Externals
While the end-user of your page builder could use the Program AST by itself to design some fairly complex components, you may still want to expose some additional functionalities.
An external is anything that is exposed to the end-user but is not defined in the State.
External Component
The first type of externals is External Components, which is simply any component that exists outside of the State. These components are typically useful when you need to expose some predefined components that your end users could reuse.
For example, let's imagine we have the following Icon React component:
tsx
Now, we can expose Icon as an ExternalComponent so that it can be referenced by a template of a RekaComponent:
tsx
External Functions
The next type of externals is External Functions. These are useful when you need to expose functions that your end-users could call. For example, you could expose an external function that your users could use to return a random number:
tsx
External State
Finally, the last type of externals is External States. These're useful if you need to store a temporary stateful value that your end-users could reference.
For example, let's say you want your end-users to be able to do something with the current scrollTop position of the page:
tsx