I’m building a widget extension with a backend service. The general idea is to provide the user with a form which will create files based on the user input on submit.
The widget (which extends ReactWidget) instantiates a React.Component on render():
That component provides the form and handles user input manipulation by storing values into its state. Once the user clicks “Submit”, I would like to be able to trigger a callback in the widget (the “parent” ReactWidget), which holds the CommandRegistry, with the ReactNode state as argument to that callback.
I failed to find examples in Theia but I might have overlooked something.
I am not sure if I got this, but you can pass down the service in the props just like in pure React. Here is an example, if you are looking for something like this.
Thank you, I’m currently looking into it. I must say I am not familiar with React and I’m struggling to initialize my view’s props. Here is the complete snippet for the form component:
No worries. I added a quick example. Open the Sample Unclosable View and see how it works. Also, check the console (in the dev tools). My example does not call the command service eventually, but it’s there. You can use it. I hope this helps.