How to generate list when word is selected?

Keywords: reactjs material-ui


How can I generate list with words that is attached to the selected word?

I have a table like this:


I eat banana

I have beautiful car

Lets say person double click on word banana, thus it is selected.

I need to generate component with other words that is attached to the selected word.


You can listen to the selectionchange event, figure out if the new selection is in one of your list elements (using refs or ReactDOM.findDOMNode() to keep track of them) then read the selection's text and then do your usual React magic to generate the other component.