Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
ui/react: update React types
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-sokolov committed Mar 2, 2021
1 parent 179f9d2 commit d2ba44a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/ui/react/configure.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ReactNode } from "react";
import { create, CreateParams, Data } from "../../core";
import { createContext } from "./context";
import { makeHooks } from "./hooks";
Expand All @@ -18,7 +19,7 @@ export function configure<Domain>(configuration: Configuration<Domain>) {
...hooks,
create: (params: CreateParams<Domain>) => {
const db = create<Domain>({ ...params, initialData: data });
const withDB = (children: React.ReactNode) =>
const withDB = (children: ReactNode) =>
React.createElement(Provider as any, { value: db, children: children });
return { db, withDB };
},
Expand Down
5 changes: 3 additions & 2 deletions src/ui/react/inputs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { ChangeEvent, InputHTMLAttributes } from "react";
import type { ReactType } from "./types";

export function makeSemiControlledInput(React: ReactType) {
return function SemiControlledInput(
props: React.InputHTMLAttributes<HTMLInputElement>
props: InputHTMLAttributes<HTMLInputElement>
) {
const { defaultValue, onBlur, onChange, onFocus, value } = props;
if (defaultValue !== undefined)
Expand All @@ -15,7 +16,7 @@ export function makeSemiControlledInput(React: ReactType) {
...props,
onBlur: (e) => {
if (onChange && valueUnderEdit !== value)
onChange({ target: e.target } as React.ChangeEvent<HTMLInputElement>);
onChange({ target: e.target } as ChangeEvent<HTMLInputElement>);
if (onBlur) onBlur(e);
setFocused(false);
},
Expand Down

0 comments on commit d2ba44a

Please sign in to comment.