import { Plugin } from '@root'
const MyCustomComponent = () => {
const config = Plugin.useConfig()
return (
<div>
<p>title: {config.title}</p>
</div>
)
}
export default MyCustomComponent
useConfig accepts a selector as an argument to select a part of the config instead of returning all the config object
{
[...]
service: {
endpoint: "http://my-awsome-service.com",
credentials: {
username: "mr.awesome",
password: "supper-secret"
}
}
[...]
}
import { Plugin } from '@root'
import { useEffect } from 'react'
const MyCustomComponent = () => {
const service = Plugin.useConfig(config => config.service)
useEffect(() => {
connect(service.endpoint, service.credentials})
}, [])
}
export default MyCustomComponent