Invoke command from React.Component? #607
Replies: 6 comments
-
|
Posted by: on 2/17/2021, 10:57:35 AM 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. github.comeclipse-theia/theia/blob/f3a15db2e364549922a843f195371f5a19a1a403/packages/timeline/src/browser/timeline-tree-widget.tsx#L52-L56 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Posted by: on 2/17/2021, 11:35:52 AM
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. |
Beta Was this translation helpful? Give feedback.
-
|
Posted by: on 2/17/2021, 11:41:02 AM This is great. Thank you very much. I got close but you just nailed it! Now I just have to find out how to declare commands which accept arguments |
Beta Was this translation helpful? Give feedback.
-
|
Posted by: on 2/17/2021, 9:13:47 PM
You can take a look at our test cases for an example on a command that can accept arguments: github.comeclipse-theia/theia/blob/f3a15db2e364549922a843f195371f5a19a1a403/packages/core/src/common/command.spec.ts#L32-L38You can take a look how the command is registered, and how to invoke it |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
-
Posted by: on 2/17/2021, 9:35:52 AM
Hi,
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 aReact.Componentonrender():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 theCommandRegistry, with the ReactNode state as argument to that callback.I failed to find examples in Theia but I might have overlooked something.
Could someone provide me with any pointer?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions