Created
January 15, 2016 16:47
-
-
Save lukegb/9609de88a2a09093b435 to your computer and use it in GitHub Desktop.
Calling React from Python? Certainly!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dukpy | |
ctx = dukpy.RequirableContext(['/homes/leg13/test/node_modules']) | |
ret = ctx.evaljs(""" | |
var React = require('react'); | |
var HelloWorld = React.createClass({ | |
render: function() { | |
return React.createElement('p', null, 'Hi!'); | |
} | |
}); | |
({ | |
React: React, | |
HelloWorld: HelloWorld | |
}) | |
""") | |
React = ret.React | |
HelloWorld = ret.HelloWorld | |
print(React.renderToString(React.createElement(HelloWorld, None, ''))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh wow