[GH-ISSUE #86] Cannot read property 'setChild' of undefined #52

Closed
opened 2026-05-05 11:32:49 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @mischnic on GitHub (Apr 28, 2018).
Original GitHub issue: https://github.com/kusti8/proton-native/issues/86

The app starts just fine, displaying the textarea and the button. Deleting all text in the textarea also removes the button. But typing something into the area afterwards causes a crash:

Code:

import React, { Component } from 'react';
import { render, Window, App, TextInput, Box, Button } from 'proton-native';

class Notepad extends Component {
  state = { text: 'Hello' };

  render() {
    return (
      <App>
        <Window title="Notes" size={{ w: 500, h: 500 }}>
          <Box>
            <TextInput
              onChange={text => this.setState({ text })}
              multiline={true}
            >
              {this.state.text}
            </TextInput>
            {this.state.text.length > 0 && <Button>Test</Button>}
          </Box>
        </Window>
      </App>
    );
  }
}

render(<Notepad />);
$ babel-node index.js
The above error occurred in the <BUTTON> component:
    in BUTTON (created by Notepad)
    in VERTICALBOX (created by Box)
    in Box (created by Notepad)
    in WINDOW (created by Notepad)
    in APP (created by Notepad)
    in Notepad

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:6780
      throw _error4;
      ^

TypeError: Cannot read property 'setChild' of undefined
    at Button.addParent (/????/proton-notepad/node_modules/proton-native/bin/components/DesktopComponent.js:148:38)
    at Button.render (/????/proton-notepad/node_modules/proton-native/bin/components/Button.js:53:12)
    at appendChild (/????/proton-notepad/node_modules/proton-native/bin/reconciler/index.js:70:53)
    at commitPlacement (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:4909:13)
    at commitAllHostEffects (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:5681:13)
    at Object.invokeGuardedCallback$1 (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:1562:10)
    at invokeGuardedCallback (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:1509:29)
    at commitRoot (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:5801:9)
    at performWorkOnRoot (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:6803:42)
    at performWork (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:6753:7)
error Command failed with exit code 1.
Originally created by @mischnic on GitHub (Apr 28, 2018). Original GitHub issue: https://github.com/kusti8/proton-native/issues/86 The app starts just fine, displaying the textarea and the button. Deleting all text in the textarea also removes the button. But typing something into the area afterwards causes a crash: Code: ```jsx import React, { Component } from 'react'; import { render, Window, App, TextInput, Box, Button } from 'proton-native'; class Notepad extends Component { state = { text: 'Hello' }; render() { return ( <App> <Window title="Notes" size={{ w: 500, h: 500 }}> <Box> <TextInput onChange={text => this.setState({ text })} multiline={true} > {this.state.text} </TextInput> {this.state.text.length > 0 && <Button>Test</Button>} </Box> </Window> </App> ); } } render(<Notepad />); ``` ``` $ babel-node index.js The above error occurred in the <BUTTON> component: in BUTTON (created by Notepad) in VERTICALBOX (created by Box) in Box (created by Notepad) in WINDOW (created by Notepad) in APP (created by Notepad) in Notepad Consider adding an error boundary to your tree to customize error handling behavior. Visit https://fb.me/react-error-boundaries to learn more about error boundaries. /????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:6780 throw _error4; ^ TypeError: Cannot read property 'setChild' of undefined at Button.addParent (/????/proton-notepad/node_modules/proton-native/bin/components/DesktopComponent.js:148:38) at Button.render (/????/proton-notepad/node_modules/proton-native/bin/components/Button.js:53:12) at appendChild (/????/proton-notepad/node_modules/proton-native/bin/reconciler/index.js:70:53) at commitPlacement (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:4909:13) at commitAllHostEffects (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:5681:13) at Object.invokeGuardedCallback$1 (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:1562:10) at invokeGuardedCallback (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:1509:29) at commitRoot (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:5801:9) at performWorkOnRoot (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:6803:42) at performWork (/????/proton-notepad/node_modules/react-reconciler/cjs/react-reconciler.development.js:6753:7) error Command failed with exit code 1. ```
Author
Owner

@neslinesli93 commented on GitHub (May 2, 2018):

Having the same exact error here, and it happens when components are added/removed "dynamically": for example if you try to render a <Text /> component based on a boolean condition, everything crashes with the very same error

<!-- gh-comment-id:386120812 --> @neslinesli93 commented on GitHub (May 2, 2018): Having the same exact error here, and it happens when components are added/removed "dynamically": for example if you try to render a `<Text />` component based on a boolean condition, everything crashes with the very same error
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/proton-native#52
No description provided.