-
Notifications
You must be signed in to change notification settings - Fork 928
/
IRenderFunctions.cs
48 lines (41 loc) · 1.92 KB
/
IRenderFunctions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
namespace React
{
/// <summary>
/// Functions to execute during a render request.
/// These functions will share the same Javascript context, so state can be passed around via variables.
/// </summary>
public interface IRenderFunctions
{
/// <summary>
/// Executes before component render.
/// It takes a func that accepts a Javascript code expression to evaluate, which returns the result of the expression.
/// This is useful for setting up variables that will be referenced after the render completes.
/// <param name="executeJs">The func to execute</param>
/// </summary>
void PreRender(Func<string, string> executeJs);
/// <summary>
/// Transforms the React.createElement expression.
/// This is useful for libraries like styled components which require wrapping the root component
/// inside a helper to generate a stylesheet.
/// Example transform: React.createElement(Foo, ...) => wrapComponent(React.createElement(Foo, ...))
/// </summary>
/// <param name="componentToRender">The Javascript expression to wrap</param>
/// <returns>A wrapped expression</returns>
string WrapComponent(string componentToRender);
/// <summary>
/// Transforms the compiled rendered component HTML
/// This is useful for libraries like emotion which take rendered component HTML and output the transformed HTML plus additional style tags
/// </summary>
/// <param name="input">The component HTML</param>
/// <returns>A wrapped expression</returns>
string TransformRenderedHtml(string input);
/// <summary>
/// Executes after component render.
/// It takes a func that accepts a Javascript code expression to evaluate, which returns the result of the expression.
/// This is useful for reading computed state, such as generated stylesheets or a router redirect result.
/// </summary>
/// <param name="executeJs">The func to execute</param>
void PostRender(Func<string, string> executeJs);
}
}