Basically, rather than having a hardcoded number in the code, we extract it from config with key 'tasks.itemsPerPage'. We utilize the useConfig hook for this purpose, that is imported from the @bluebase/core package.
Note that the useConfig hook has the same API as the useState hook in the react library.
Now that we are using the config, we also need to define its default value. Add the defaultConfigs object to your plugin as shown in the code below:
src/index.ts
import { createPlugin } from '@bluebase/core';
export default createPlugin({
key: 'tasks',
name: 'Tasks',
description: 'A todo app made with BlueBase framework.',
defaultConfigs: {
'tasks.itemsPerPage': 10,
}
// ... other properties
});
Now run your app and inspect. You will observe that BlueBase has successfully loaded the default config, which has been passed onto the GraphqlList component.
Step 1.3: Override Config Value
Now comes the fun part. Let's override this value from our app's configs:
export * from './TaskSettingsForm';
import { TaskSettingsForm } from './TaskSettingsForm';
export default TaskSettingsForm;
Step 2.2 Add Screen in the Settings App
Now we want to create a screen for "Tasks" in the Settings app. Luckily the Settings app allows this to be done via bluebase.plugin.setting-app.pages filter.
This filter inputs an array of screens in the settings app, all we have to do is to append our own screen configs and return the array. Create a new file and copy the following code:
Note that in Line 22 till 27 we define the "Task Settings" panel and use the TaskSettingsForm component that we created in the previous step.
Let's add this filter to the plugin (See Line 13):
src/index.ts
import { createPlugin } from '@bluebase/core';
import { filters } from './filters';
import { lang } from './lang';
export default createPlugin({
key: 'tasks',
name: 'Tasks',
description: 'A todo app made with BlueBase framework.',
filters: {
...filters,
...lang,
},
// ... Other properties
});
Run the app and go to the settings section. You will see the "Tasks" settings page is added.
When you use and submit the form, you will observe that it will update the config to achieve the desired result: