NodeReact.NET icon indicating copy to clipboard operation
NodeReact.NET copied to clipboard

Feature Request: Render functions like ReactJS.Net

Open xtroncode opened this issue 3 years ago • 10 comments

Hi, I want to try this library but the lack of support for Render functions is a blocker for me. Can it be implemented in NodeReact.Net ? I'd be happy to help.

xtroncode avatar Aug 18 '20 06:08 xtroncode

@DaniilSokolyuk is there any likelihood that this would be looked into?

The library is very promising but not having the ability to support CSS-in-JS libraries via Render Functions is also a blocker for me.

rshackleton avatar Feb 16 '23 20:02 rshackleton

Just having a very quick look and I guess the approach would be much trickier whilst supporting streaming.

https://styled-components.com/docs/advanced#streaming-rendering

Perhaps a custom interop would be needed to coordinate the renderToNodeStream wrapper?

rshackleton avatar Feb 16 '23 21:02 rshackleton

We're using the new 'renderToPipeableStream' API. Additionally, we have the ability to render an entire page in a React component, like this https://github.com/DaniilSokolyuk/NodeReact.NET/blob/master/NodeReact.Sample.Streaming/ClientApp/components/App.jsx

DaniilSokolyuk avatar Feb 16 '23 21:02 DaniilSokolyuk

Issue is here https://github.com/styled-components/styled-components/issues/3658

DaniilSokolyuk avatar Feb 16 '23 21:02 DaniilSokolyuk

That is interesting, I was looking at whether we could use this to migrate away from ReactJS.NET and retain the island architecture approach vs rendering the entire site as a React app.

My concern is enabling SSR for React components within a .NET site which needs to run on Razor in order to interface with the CMS.

I suppose the CSS-in-JS issue could be circumvented by using a library that doesn't have runtime JS like Linaria or Vanilla Extract, or using something like Tailwind.

rshackleton avatar Feb 16 '23 21:02 rshackleton

I will try next week to make a legacy mode that uses renderToString

DaniilSokolyuk avatar Feb 17 '23 09:02 DaniilSokolyuk

That would be great for backwards compatibility. I'm going to trial it on a project which is currently using Tailwind. The lack of render functions shouldn't be an issue in this case.

rshackleton avatar Feb 17 '23 10:02 rshackleton

Just an update here. I have a working POC to handling CSS-in-JSS libraries like Styled and Emotion. I got the ideas from the Emotion creator as he worked with Styled, NextJS and the react devs to try to find a workaround until some new APIs posisble come out from the React devs.

I needed this support for MUI which I use heavily. the POC is pretty ugly but was waiting on another issue on posted to see if a pull request would be allowed. I havent heard back yet so i might just fork this project and clean up my POC

LorenDorez avatar Aug 07 '23 14:08 LorenDorez

@LorenDorez please share your fork here if you do. 👍

rshackleton avatar Aug 12 '23 15:08 rshackleton