Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Ensure component renders for modules get overridden
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Apr 6, 2022
1 parent d093606 commit 6421db6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/modules/ModuleComponents.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// TODO: @@ Is this future-proof enough? Will we remember to do this for new components?
import { TextInputField } from "@matrix-org/react-sdk-module-api/lib/components/TextInputField";
import { Spinner as ModuleSpinner } from "@matrix-org/react-sdk-module-api/lib/components/Spinner";
import React from "react";
import Field from "../components/views/elements/Field";
import Spinner from "../components/views/elements/Spinner";

TextInputField.renderFactory = (props) => (
<Field
type="text"
value={props.value}
onChange={e => props.onChange(e.target.value)}
label={props.label}
autoComplete="off"
/>
);
ModuleSpinner.renderFactory = () => <Spinner />;
1 change: 1 addition & 0 deletions src/modules/ModuleRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { TranslationStringsObject } from "@matrix-org/react-sdk-module-api/lib/t
import { AppModule } from "./AppModule";
import { ModuleFactory } from "./ModuleFactory";
import { AnyLifecycle } from "@matrix-org/react-sdk-module-api/lib/lifecycles/types";
import "./ModuleComponents";

export class ModuleRunner {
public static readonly instance = new ModuleRunner();
Expand Down

0 comments on commit 6421db6

Please sign in to comment.