Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Register Knockout React components together
function (log,
_myReactComponent) {
'use strict';
function ComponentsRegistry() {'Init component registry');
ComponentsRegistry.prototype.init = function () {
// This component can now be added to the DOM - assuming an existing KO app - like so:
// <my-component></my-component>
ko.components.register('my-component', wrapReactComponentInKO(_myReactComponent.MyComponent));
* @See KnockoutReactBinding.js
function wrapReactComponentInKO(reactComponent) {
return {
// By default supply the React component to the template
viewModel: function () {
return {'reactComponent': reactComponent}
// By default the component just has the react binding
template: '<div data-bind="react: reactComponent"/>'
return new ComponentsRegistry();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment