pmndrs / react-nil

⃝ A react null renderer
MIT License
793 stars 14 forks source link

Return data ? #5

Closed tony-go closed 2 years ago

tony-go commented 4 years ago

This is more a question than an issue. (sorry for that)

Are those "components" should not return data? Or should react-nil provide a new type of "components" that return data (object, array,...) instead of return null.

Just an idea.

drcmda commented 4 years ago

in react components do not return data but v-dom which goes into the hands of the reconciler. there is no component that receives the return value of another.

you have props

function Foo({ data }) {
  return <Bar data={...} />

render props

<Foo>
  {data => ( ... )}
</Foo>

i have seen a mini react for node whose components do return data, the problem is that A. this seems kinda shaky because components are async, and B. it would sacrifice the entire react eco system. it could not just go and use redux, react-graphql or whatever on the server.

tony-go commented 4 years ago

Props and render props could work in fact ^^

Thanks for the response ^^

CodyJasonBennett commented 2 years ago

Implemented this in #12.