mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
16 lines
515 B
JavaScript
16 lines
515 B
JavaScript
import React, {useContext} from 'react';
|
|
import {useStreamWithUpdater} from "./effects";
|
|
import {ReactApplicationContext} from "cad/dom/ReactApplicationContext";
|
|
|
|
export default function bind(streamProvider) {
|
|
return function (Component) {
|
|
return function Connected (props) {
|
|
|
|
const context = useContext(ReactApplicationContext);
|
|
const [value, updater] = useStreamWithUpdater(streamProvider(context, props));
|
|
|
|
|
|
return <Component value={value} onChange={updater} {...props} />;
|
|
};
|
|
};
|
|
}
|