mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-19 16:03:00 +00:00
vendor tiny subset of unmaintained recompose
the functions we use haven't changed in almost 10 years, and are only a few lines we should probably lose them eventually, but easier to vendor them first
This commit is contained in:
@@ -45,7 +45,6 @@
|
|||||||
"react-icons": "^5.5.0",
|
"react-icons": "^5.5.0",
|
||||||
"react-redux": "^9.2.0",
|
"react-redux": "^9.2.0",
|
||||||
"react-router": "^7.4.0",
|
"react-router": "^7.4.0",
|
||||||
"recompose": "npm:react-recompose@^0.33.0",
|
|
||||||
"redux": "^5.0.1",
|
"redux": "^5.0.1",
|
||||||
"regenerator-runtime": "^0.14.1"
|
"regenerator-runtime": "^0.14.1"
|
||||||
},
|
},
|
||||||
|
@@ -2,7 +2,7 @@ import React from "react";
|
|||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import { Provider } from "react-redux";
|
import { Provider } from "react-redux";
|
||||||
import { createStore } from "redux";
|
import { createStore } from "redux";
|
||||||
import { compose } from "recompose";
|
import { compose } from "./util/_recompose";
|
||||||
import { initialState, reducers } from "./Store";
|
import { initialState, reducers } from "./Store";
|
||||||
import withAPI from "./util/withAPI";
|
import withAPI from "./util/withAPI";
|
||||||
import { HashRouter, Routes, Route } from "react-router";
|
import { HashRouter, Routes, Route } from "react-router";
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import React, { act } from "react";
|
import React, { act } from "react";
|
||||||
import { withProps } from "recompose";
|
import { withProps } from "../../util/_recompose";
|
||||||
import "@testing-library/jest-dom";
|
import "@testing-library/jest-dom";
|
||||||
import userEvent from "@testing-library/user-event";
|
import userEvent from "@testing-library/user-event";
|
||||||
import {
|
import {
|
||||||
|
35
jsx/src/util/_recompose.js
Normal file
35
jsx/src/util/_recompose.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
// extracted tiny subset we use from react-recompose
|
||||||
|
// we probably don't need these at all,
|
||||||
|
// but vendor before refactoring
|
||||||
|
|
||||||
|
// https://github.com/acdlite/recompose
|
||||||
|
// License: MIT
|
||||||
|
// Copyright (c) 2015-2018 Andrew Clark
|
||||||
|
|
||||||
|
import { createElement } from "react";
|
||||||
|
|
||||||
|
function createFactory(type) {
|
||||||
|
return createElement.bind(null, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const compose = (...funcs) =>
|
||||||
|
funcs.reduce(
|
||||||
|
(a, b) =>
|
||||||
|
(...args) =>
|
||||||
|
a(b(...args)),
|
||||||
|
(arg) => arg,
|
||||||
|
);
|
||||||
|
|
||||||
|
const mapProps = (propsMapper) => (BaseComponent) => {
|
||||||
|
const factory = createFactory(BaseComponent);
|
||||||
|
const MapProps = (props) => factory(propsMapper(props));
|
||||||
|
return MapProps;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const withProps = (input) => {
|
||||||
|
const hoc = mapProps((props) => ({
|
||||||
|
...props,
|
||||||
|
...(typeof input === "function" ? input(props) : input),
|
||||||
|
}));
|
||||||
|
return hoc;
|
||||||
|
};
|
@@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { withProps } from "recompose";
|
|
||||||
import { Col, Row, Container } from "react-bootstrap";
|
import { Col, Row, Container } from "react-bootstrap";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
import { withProps } from "./_recompose";
|
||||||
import ErrorAlert from "./error";
|
import ErrorAlert from "./error";
|
||||||
|
|
||||||
export const MainCol = (props) => {
|
export const MainCol = (props) => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { withProps } from "recompose";
|
import { withProps } from "./_recompose";
|
||||||
import { jhapiRequest } from "./jhapiUtil";
|
import { jhapiRequest } from "./jhapiUtil";
|
||||||
|
|
||||||
const withAPI = withProps(() => ({
|
const withAPI = withProps(() => ({
|
||||||
|
Reference in New Issue
Block a user