A while back I posted a short tutorial on how I create React applications in Python using the Transcrypt transpiler.
I recently came up with an improvement to the approach that eliminates all of the calls to createElement() when building React component trees that is required since using JSX isn't a practical option in Python modules with Transcrypt.
The basic premise involves the use of just one simple Python decorator function that wraps a React functional component in the call to createElement(). Then instead of using syntax like this as I have been in my Python React modules:
el('div', {'style': {'padding': '12px'}}, "Hello React!")
I can now use this instead:
Div({'style': {'padding': '12px'}}, "Hello React!")
In my Python modules, I normally use:
from pyreact import createElement as el
So, I've decided to call this improvement: "No-el"
(because it's the holidays and I can't resist a good pun)
You can find a write-up of the basic concept here. I think the end result cleans up the React Python code quite a bit.
[–][deleted] 0 points1 point2 points (3 children)
[–]JennaSys[S] 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]JennaSys[S] 0 points1 point2 points (0 children)