You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/javascript/render-functions.md
+11-11
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,20 @@
1
-
# React on Rails RenderFunctions: Usage Guide
1
+
# React on Rails Render-Functions: Usage Guide
2
2
3
-
This guide explains how renderfunctions 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.
4
4
5
-
## Types of RenderFunctions and Their Return Values
5
+
## Types of Render-Functions and Their Return Values
6
6
7
-
Renderfunctions take two parameters:
7
+
Render-functions take two parameters:
8
8
9
9
1.`props`: The props passed from the Ruby helper methods (via the `props:` parameter), which become available in your JavaScript.
10
10
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.
11
11
12
-
### Identifying RenderFunctions
12
+
### Identifying Render-Functions
13
13
14
-
React on Rails needs to identify which functions are renderfunctions (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:
15
15
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.
This helper accepts renderfunctions 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.
143
143
144
144
#### When to use:
145
145
@@ -173,7 +173,7 @@ The `react_component_hash` helper is used when your render function returns an o
173
173
</div>
174
174
```
175
175
176
-
This helper accepts renderfunctions 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.
0 commit comments