This migration is only relevant if you're using TypeScript and a React UI for Admin.
If you created a complex React UI, this migration will take some time; you may decide not to migrate to adapter-react
for this reason.
Just keep in mind you won't profit from future improvements to the React UI in create-adapter
.
- Update
.eslintrc.js
to look like this- Add ECMA Feature JSX
- Extend the rules from
plugin:react/recommended
- Add the plugin
react
- Set the React version to
detect
- Update
package.json
- Add the latest version of the following packages as dev dependencies:
@iobroker/adapter-react
@material-ui/core
@material-ui/icons
eslint-plugin-react
react-icons
- Remove the following packages:
@types/jquery
@types/materialize-css
- Add the latest version of the following packages as dev dependencies:
- Update
.npmignore
to look like this
- Add the file
src/lib/adapter-config.d.ts
with your adapter configuration similar to this. - Remove the following files because all methods related to ioBroker communication are now taken from
@iobroker/adapter-react
(see also under "Admin Content"):lib/admin.d.ts
lib/backend.ts
- Update
admin/index_m.html
to look like this- You shouldn't have to edit this file during development.
- Update
admin/src/index.tsx
to look like this- Ensure you use your own adapter name (without "iobroker.") in the line
window["adapterName"] = "YOUR ADAPTER NAME HERE";
- Ensure you use your own adapter name (without "iobroker.") in the line
- Remove
admin/words.js
and put all translations in JSON files:- Path:
admin/src/i18n/[language].json
- One file for each language
- JSON format: key-value pairs
- Path:
- Create your UI in
admin/src/app.tsx
and linked files- You sould start from admin/src/app.tsx
- You can look at admin/src/components/settings.tsx for some inspiration
- Use components from
@material-ui
(MUI) where possible. Examples:- Text Field in
@material-ui/core/TextField
- Checkbox in
@material-ui/core/Checkbox
- Dropdown in
@material-ui/core/Select
- Text Field in
- Use built-in types from ioBroker where possible.
- Documentation: https://github.com/ioBroker/adapter-react/#components
- Examples:
- Tab Container
- Dialogs (Message, Confirm, Error, Text Input, Select Object ID)
- File Browser
- Icons (Copy, Expert, ...)
- For advanced communication with the ioBroker host, the class
Connection
provides all possible methods- get / set objects, states, ...
- subscribe to objects and states
- send messages
- ... and many more