cyclejs / react Goto Github PK
View Code? Open in Web Editor NEWUtilities to interoperate between Cycle.js and React
License: MIT License
Utilities to interoperate between Cycle.js and React
License: MIT License
All is in the title :-)
Thank you.
react source's props()
method gets Root component props stream for any selected source.
sources.react.select(sel).props() // gets root component props stream not selected by `sel`
Is it by design? It is logical to propose that it should provide props stream for a selected component.
React instances are duplicated when using cycle/react, because cycle/react defines react as a regular dependency instead of a peerDependency in package.json. This not only bloats the bundle files up, but also makes writing extensions harder, because in some low-level cases, these instances can mix up (especially when I'm playing with JSX pragmas). Currently these are regular dependencies package.json:
"dependencies": {
"@cycle/run": "5.x.x",
"react": "16.5.x",
"xstream": "11.x.x"
},
I think all of these should be in the peerDependencies block.
Full code here: https://codesandbox.io/s/quirky-butterfly-0pdjd?file=/src/index.ts
function main(sources: any) {
const counter = Counter(sources, xs.of(2));
const other = Counter(sources, xs.of(1));
return {
react: xs
.combine(counter.DOM, other.DOM)
.map((els) => h("div", els))
};
}
const App = makeComponent(main, {});
render(h(App), document.getElementById("app"));
Given the code above, I get an empty webpage with no components rendered, even though the DOM stream does fire with valid component data.
I can make this work by either removing drivers:
makeComponent(main)
or by replacing my Counter components with something trivial:
.combine(
xs.of(h("div", "one")),
xs.of(h("div", "two"))
)
I suspect that there is a bug somewhere in makeComponent
code where it branches on non-null drivers
argument, but I haven't done any actual investigation.
Your blog post https://staltz.com/use-react-in-cyclejs-and-vice-versa.html mentions that you want hyperscript to be the first class citizen, and JSX second, but I was wondering if in fact the React JSX key
isn't a good candidate for being use as sel
?
I'm having some problems using cycle-react in my own components if these are imported from other packages.
When importing the hyperscript function directly from cycle/react
everything works fine. But when I import a HOC from another package, things start to not work as expected.
For what I can debug, ForwardRef
s are created ok. However, no event listener is attached to the html element. In this screenshot, the element in the second button appears with no handler using react devTools.
I've created a repo that reproduces this issue using a lerna monorepo.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.