Skip to content

Instantly share code, notes, and snippets.

@klzns klzns/example.html
Created Jul 11, 2018

Embed
What would you like to do?
React dentro de AngularJS
<react component="vtex.Hello" props=something.insideAngularScope"></react>
angular.module('vtex.react', [])
.directive 'react', ($translate) ->
restrict: 'E'
scope: {
component: '@',
props: '=',
},
link: (scope, elem, attrs) ->
componentPath = scope.component.split('.')
component = componentPath.reduce(((component, path) -> component[path]), window)
container = elem[0]
ReactDOM.render(
React.createElement(component, scope.props),
container
)
elem.on '$destroy', () ->
ReactDOM.unmountComponentAtNode(container)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.