Skip to content

Commit 0306315

Browse files
Update documentation to standardize terminology by changing "render functions" to "render-functions"
1 parent c7e3a2a commit 0306315

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

docs/javascript/render-functions.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# React on Rails Render Functions: Usage Guide
1+
# React on Rails Render-Functions: Usage Guide
22

3-
This guide explains how render functions work in React on Rails and how to use them with Ruby helper methods.
3+
This guide explains how render-functions work in React on Rails and how to use them with Ruby helper methods.
44

5-
## Types of Render Functions and Their Return Values
5+
## Types of Render-Functions and Their Return Values
66

7-
Render functions take two parameters:
7+
Render-functions take two parameters:
88

99
1. `props`: The props passed from the Ruby helper methods (via the `props:` parameter), which become available in your JavaScript.
1010
2. `railsContext`: Rails contextual information like current pathname, locale, etc. See the [Render-Functions and the Rails Context](https://www.shakacode.com/react-on-rails/docs/guides/render-functions-and-railscontext/) documentation for more details.
1111

12-
### Identifying Render Functions
12+
### Identifying Render-Functions
1313

14-
React on Rails needs to identify which functions are render functions (as opposed to regular React components). There are two ways to mark a function as a render function:
14+
React on Rails needs to identify which functions are render-functions (as opposed to regular React components). There are two ways to mark a function as a render function:
1515

16-
1. Accept two parameters in your function definition: `(props, railsContext)` - React on Rails will detect this signature
17-
2. Add a `renderFunction = true` property to your function - This is useful when your function doesn't need the railsContext
16+
1. Accept two parameters in your function definition: `(props, railsContext)` - React on Rails will detect this signature (the parameter names don't matter).
17+
2. Add a `renderFunction = true` property to your function - This is useful when your function doesn't need the railsContext.
1818

1919
```jsx
2020
// Method 1: Use signature with two parameters
@@ -35,7 +35,7 @@ MyOtherComponent.renderFunction = true;
3535
ReactOnRails.register({ MyComponent, MyOtherComponent });
3636
```
3737

38-
Render functions can return several types of values:
38+
Render-functions can return several types of values:
3939

4040
### 1. React Components
4141

@@ -139,7 +139,7 @@ The `react_component` helper renders a single React component in your view.
139139
<%= react_component("MyComponent", props: { name: "John" }) %>
140140
```
141141
142-
This helper accepts render functions that return React components, objects with a `renderedHtml` property, or promises that resolve to React components, or strings.
142+
This helper accepts render-functions that return React components, objects with a `renderedHtml` property, or promises that resolve to React components, or strings.
143143
144144
#### When to use:
145145
@@ -173,7 +173,7 @@ The `react_component_hash` helper is used when your render function returns an o
173173
</div>
174174
```
175175

176-
This helper accepts render functions that return objects with a `renderedHtml` property containing `componentHtml` and any other necessary properties. It also supports promises that resolve to a server-side hash.
176+
This helper accepts render-functions that return objects with a `renderedHtml` property containing `componentHtml` and any other necessary properties. It also supports promises that resolve to a server-side hash.
177177

178178
#### When to use:
179179

node_package/src/types/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type RenderFunctionResult = RenderFunctionSyncResult | RenderFunctionAsyncResult
7272
type StreamableComponentResult = ReactElement | Promise<ReactElement | string>;
7373

7474
/**
75-
* Render functions are used to create dynamic React components or server-rendered HTML with side effects.
75+
* Render-functions are used to create dynamic React components or server-rendered HTML with side effects.
7676
* They receive two arguments: props and railsContext.
7777
*
7878
* @param props - The component props passed to the render function
@@ -133,7 +133,7 @@ export interface RegisteredComponent {
133133
// Indicates if the registered component is a Renderer function.
134134
// Renderer function handles DOM rendering or hydration with 3 args: (props, railsContext, domNodeId)
135135
// Supported on the client side only.
136-
// All renderer functions are render functions, but not all render functions are renderer functions.
136+
// All renderer functions are render-functions, but not all render-functions are renderer functions.
137137
isRenderer: boolean;
138138
}
139139

0 commit comments

Comments
 (0)