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