Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Views rendering Views as children #67

Open
JohnPaulHarold opened this issue Jan 30, 2021 · 4 comments
Open

Views rendering Views as children #67

JohnPaulHarold opened this issue Jan 30, 2021 · 4 comments

Comments

@JohnPaulHarold
Copy link

JohnPaulHarold commented Jan 30, 2021

I'm seeing an oddity when rendering something like this

const s = StyleSheet.create({
  container: {
    backgroundColor: 'aliceblue',
    height: 300,
    width: 200,
  },
  child: {
    height: 100,
    width: 100,
  }
})
<View style={s.container}>
  {["bisque", "cadetblue", "darkseagreen"].map((c, i) => (
    <View style={{...s.child, backgroundColor: c}}>
      <Text content={`Child ${i+1}`} />
    </View>
  ))}
</View>

I'd expect to see this, more or less:

Screenshot 2021-01-30 at 17 37 50

instead, it's positioning the parent <View/> after the children. Like this

Screenshot 2021-01-30 at 15 39 00

You can also see similar drawing setting the container to something like, {position: 'absolute', left: 100, top: 100}

Screenshot 2021-01-30 at 19 51 42

I think the issue is around here, https://github.com/raphamorim/react-ape/blob/master/packages/react-ape/renderer/elements/View.js#L52-L56

Also, it seems as though the views are rendered in order of child to parent. With that in mind, I'm not sure how you can render such a list without recomputing the child positions when you finally know the position of the parent. Although, I could be wrong. That happens often.

@JohnPaulHarold
Copy link
Author

JohnPaulHarold commented Jan 31, 2021

Small update:

I've got it rendering like so. it shows 1 parent view, and 2 child views. Inside each child view are three more child views. Inside those, text. Will test it some more as it ended up touching the renderer and the View element code.

Screenshot 2021-01-31 at 19 47 05

What isn't happening, is the container <View/> using a height that is the sum of the children. You can see that with the root node which is still using the default size values of a <View/>

@raphamorim
Copy link
Owner

Hey @JohnPaulHarold , sorry for the late reply. I wasn't working on this project much last year. I have made changes on the View rendering logic lately, could check if it's still valid?

@JohnPaulHarold
Copy link
Author

Hello @raphamorim Sorry for the delay. I'm still seeing the same issue. Just in case I've done something silly, I did:

  • fresh clone of react-ape with package.json reporting, "version": "0.0.9-alpha.4",
  • npm i and the cd to packages/app
  • inside App.js I replaced the return of render() with my simple example, and also modified the stylesheet.
  • still seeing the same

Screenshot 2022-06-25 at 14 26 32

@raphamorim
Copy link
Owner

I see, thank you @JohnPaulHarold for the reply. Will try to fix it along with the #124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

2 participants