[GH-ISSUE #171] Area.Text does not update #109

Closed
opened 2026-05-05 11:43:44 -06:00 by gitea-mirror · 5 comments
Owner

Originally created by @grimmen on GitHub (Aug 25, 2018).
Original GitHub issue: https://github.com/kusti8/proton-native/issues/171

In the sample below, when the button is clicked only the first text line changes in the UI. The Area.Text component keeps displaying the initial value.

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

class Example extends Component {
  state = { flag: false };

  flagText() {
    return "Flag is "+(this.state.flag ? "Set" : "Not Set")
  }

  render() {
    return (
      <App>
        <Window title="Test" size={{ w: 600, h: 250 }} >
          <Box padded>
            <Text>{this.flagText()}</Text>
            <Area>
              <Area.Text>{this.flagText()}</Area.Text>
            </Area>
            <Button onClick={() =>
                this.setState({
                  flag: !this.state.flag,
                })
              }>Toggle Flag</Button>
          </Box>
        </Window>
      </App>
    );
  }
}

render(<Example />);
Originally created by @grimmen on GitHub (Aug 25, 2018). Original GitHub issue: https://github.com/kusti8/proton-native/issues/171 In the sample below, when the button is clicked only the first text line changes in the UI. The Area.Text component keeps displaying the initial value. ```js import React, { Component } from 'react'; import {render, Window, App, Box, Button, Area, Text,} from 'proton-native'; class Example extends Component { state = { flag: false }; flagText() { return "Flag is "+(this.state.flag ? "Set" : "Not Set") } render() { return ( <App> <Window title="Test" size={{ w: 600, h: 250 }} > <Box padded> <Text>{this.flagText()}</Text> <Area> <Area.Text>{this.flagText()}</Area.Text> </Area> <Button onClick={() => this.setState({ flag: !this.state.flag, }) }>Toggle Flag</Button> </Box> </Window> </App> ); } } render(<Example />); ```
Author
Owner

@mischnic commented on GitHub (Aug 26, 2018):

@kusti8 The problem seems to be that the AreaText class implements only appendChild, so this.children doesn't update?

<!-- gh-comment-id:416037131 --> @mischnic commented on GitHub (Aug 26, 2018): @kusti8 The problem seems to be that the AreaText class implements only `appendChild`, so `this.children` doesn't update?
Author
Owner

@kusti8 commented on GitHub (Aug 28, 2018):

Yeah, the reconciler depends on removeChild as well for mutation, which Area.Text doesn't have.
https://github.com/kusti8/proton-native/blob/master/src/reconciler/index.js#L79-L89

A reference on what DesktopComponent does:
https://github.com/kusti8/proton-native/blob/master/src/components/DesktopComponent.js#L74-L108

<!-- gh-comment-id:416603625 --> @kusti8 commented on GitHub (Aug 28, 2018): Yeah, the reconciler depends on removeChild as well for mutation, which Area.Text doesn't have. https://github.com/kusti8/proton-native/blob/master/src/reconciler/index.js#L79-L89 A reference on what DesktopComponent does: https://github.com/kusti8/proton-native/blob/master/src/components/DesktopComponent.js#L74-L108
Author
Owner

@mischnic commented on GitHub (Aug 28, 2018):

I fixed a crash regarding conditional rendering in an AreaGroup along the
way, but removeChild is never getting called in AreaText (though
appendChild is). I can only pick up the change in
AreaText.update(oldProps, newProps) .

Gustav Hansen notifications@github.com schrieb am Di., 28. Aug. 2018,
16:22:

Yeah, the reconciler depends on removeChild as well for mutation, which
Area.Text doesn't have.

https://github.com/kusti8/proton-native/blob/master/src/reconciler/index.js#L79-L89

A reference on what DesktopComponent does:

https://github.com/kusti8/proton-native/blob/master/src/components/DesktopComponent.js#L74-L108


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/kusti8/proton-native/issues/171#issuecomment-416603625,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEX9jnQZuCnn4KKE1BYXT1yRoaiiWgZGks5uVVI8gaJpZM4WMgzz
.

<!-- gh-comment-id:416697902 --> @mischnic commented on GitHub (Aug 28, 2018): I fixed a crash regarding conditional rendering in an AreaGroup along the way, but `removeChild` is never getting called in AreaText (though `appendChild` is). I can only pick up the change in `AreaText.update(oldProps, newProps) `. Gustav Hansen <notifications@github.com> schrieb am Di., 28. Aug. 2018, 16:22: > Yeah, the reconciler depends on removeChild as well for mutation, which > Area.Text doesn't have. > > https://github.com/kusti8/proton-native/blob/master/src/reconciler/index.js#L79-L89 > > A reference on what DesktopComponent does: > > https://github.com/kusti8/proton-native/blob/master/src/components/DesktopComponent.js#L74-L108 > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/kusti8/proton-native/issues/171#issuecomment-416603625>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AEX9jnQZuCnn4KKE1BYXT1yRoaiiWgZGks5uVVI8gaJpZM4WMgzz> > . >
Author
Owner

@kusti8 commented on GitHub (Aug 28, 2018):

That makes sense. If any props are being changed (including children), then update is being called. If we're actually adding or removing children, then removeChild is called. Sorry about that.

So we would have to create an update function. I haven't played with Area as much, but it looks like we just use deleteString and then append the new string?

<!-- gh-comment-id:416707011 --> @kusti8 commented on GitHub (Aug 28, 2018): That makes sense. If any props are being changed (including children), then update is being called. If we're actually adding or removing children, then removeChild is called. Sorry about that. So we would have to create an update function. I haven't played with Area as much, but it looks like we just use deleteString and then append the new string?
Author
Owner

@mischnic commented on GitHub (Aug 29, 2018):

I think I fixed it locally, but it might be a while before I have internet access to create a PR.

<!-- gh-comment-id:416902896 --> @mischnic commented on GitHub (Aug 29, 2018): I think I fixed it locally, but it might be a while before I have internet access to create a PR.
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#109
No description provided.