Skip to content

Uppercase components and push to stream #316

@pedrobslisboa

Description

@pedrobslisboa

I notice while doing some arch tests that we are wrongly pushing Upper_case_components to the stream while we should pushing nodes
Take the following code as an example:

const Bar = () => {
	return "Baz"
}

const Foo = () => {
	return (
		<Bar />
	)
}

const App = () => {
	return (
		<Foo />
	)
};

const { pipe } = renderToPipeableStream(<App />);
Ocaml test code
let nested_upper_case_components () =
  let app () =
    React.Upper_case_component
      ( "app",
        fun () ->
          React.Upper_case_component ("Foo", fun () -> React.Upper_case_component ("Bar", fun () -> React.string "Bar"))
      )
  in
  let output, subscribe = capture_stream () in
  let%lwt () = ReactServerDOM.render_model ~subscribe (app ()) in
  assert_list_of_strings !output ["2:\"Bar\"\n"; "1:\"$2\"\n"; "0:\"$1\"\n"];
  Lwt.return ()

The result on our current code is: ["2:\"Bar\"\n"; "1:\"$2\"\n"; "0:\"$1\"\n"]
While react's result is: 0:"Baz"

And that makes sense as the Upper_case_components isn't a content to be pushed, unlike Lower_case_elements / Json values / etc ...

We should change the way we push our content.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions