Skip to content

Commit

Permalink
Define new api registerRenderer
Browse files Browse the repository at this point in the history
The line doc/additional-reading/code-splitting.md should be
changed to a url when/if this proposal gets accepted.

This proposal was originally desribed here:
shakacode#477
  • Loading branch information
jtibbertsma committed Oct 21, 2016
1 parent 8b1324a commit 8c3368b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/api/javascript-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,13 @@ The best source of docs is the main [ReactOnRails.js](../../node_package/src/Rea
*/

authenticityHeaders(otherHeaders = {})

/**
* Allows registration of renderers. A renderer is a function that accept three args:
* props, railsContext, and domNodeId, and is responsible for rendering a component
* to the DOM. Not available on the server. For one possible use case see:
* docs/additional-reading/code-splitting.md
* @param renderers (key is component name, value is renderer)
*/
registerRenderer(renderers)
```
11 changes: 11 additions & 0 deletions node_package/src/ReactOnRails.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ ctx.ReactOnRails = {
return Authenticity.authenticityHeaders(otherHeaders);
},

/**
* Allows registration of renderers. A renderer is a function that accept three args:
* props, railsContext, and domNodeId, and is responsible for rendering a component
* to the DOM. Not available on the server. For one possible use case see:
* docs/additional-reading/code-splitting.md
* @param renderers (key is component name, value is renderer)
*/
registerRenderer(renderers) {
ComponentRegistry.registerRenderer(renderers);
},

// /////////////////////////////////////////////////////////////////////////////
// INTERNALLY USED APIs
// /////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 8c3368b

Please sign in to comment.