0

I know this method:

React.render(<Account/>, document.getElementById('app'));
React.unmountComponentAtNode(document.getElementById('app'));

But what if my component has been rendered like that ?

<body>
    <div id="container">
        <MyComponent/>
    </div>
</body>

Rendering function of MyComponent:

 render: function() {
       <div id=search>
           <input etc........./> 
       </div>
   }

I tried

React.unmountComponentAtNode(document.getElementById('search'));

and

React.unmountComponentAtNode(document.getElementById('container'));

but it's not working.

What should I do ?

François Richard
  • 6,817
  • 10
  • 43
  • 78
  • This question is very unclear - what are you actually trying to unmount? `Account`, `app` or `MyComponent`? Unmounting works flawlessly it's just that React can't find your component at your selectors. Working example here http://jsfiddle.net/kb3gN/11059/ – Henrik Andersson May 08 '15 at 09:06
  • Maybe http://stackoverflow.com/questions/27227792/react-js-removing-a-component is the answer you are looking for – gabrielgiussi May 08 '15 at 16:56
  • I try to unmount mycomponent – François Richard May 08 '15 at 17:21
  • 1
    Out of curiosity, why are you trying to unmount it? Have you considered changing the `render` function of its parent to render it conditionally? – Kyeotic Dec 02 '15 at 18:34

0 Answers0