diff --git a/docs/api/javascript-api.md b/docs/api/javascript-api.md index 49f608429..53cf30a27 100644 --- a/docs/api/javascript-api.md +++ b/docs/api/javascript-api.md @@ -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) ``` diff --git a/node_package/src/ReactOnRails.js b/node_package/src/ReactOnRails.js index fa4c423b0..6a3808890 100644 --- a/node_package/src/ReactOnRails.js +++ b/node_package/src/ReactOnRails.js @@ -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 // /////////////////////////////////////////////////////////////////////////////