diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ca5e0b1..449387b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +# 0.8.2 + +- Ensures that `React.PropsWithChildren` is used for components that accept children, for React 18 compatibility reasons. + +# 0.8.1 + +- Fixes a bug involving the ESM build. + ## 0.8.0 - Added the [`Transform` component](https://mafs.dev/guides/utility/transform) diff --git a/package.json b/package.json index a10c8708..eda40872 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mafs", - "version": "0.8.1", + "version": "0.8.2", "license": "MIT", "author": "Steven Petryk (https://stevenpetryk.com)", "homepage": "https://mafs.dev", diff --git a/src/display/Text.tsx b/src/display/Text.tsx index 69795043..442df688 100644 --- a/src/display/Text.tsx +++ b/src/display/Text.tsx @@ -5,7 +5,7 @@ import { useTransformContext } from "./Transform" export type CardinalDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw" -export interface TextProps { +export type TextProps = React.PropsWithChildren<{ x: number y: number attach?: CardinalDirection @@ -13,9 +13,9 @@ export interface TextProps { size?: number color?: string svgTextProps?: React.SVGAttributes -} +}> -export const Text: React.FC = ({ +export function Text({ children, x, y, @@ -24,7 +24,7 @@ export const Text: React.FC = ({ svgTextProps = {}, attach, attachDistance = 0, -}) => { +}: TextProps) { const { pixelMatrix } = useScaleContext() const transformContext = useTransformContext() diff --git a/src/view/MafsView.tsx b/src/view/MafsView.tsx index 20327b8a..5d963900 100644 --- a/src/view/MafsView.tsx +++ b/src/view/MafsView.tsx @@ -9,7 +9,7 @@ import ScaleContext, { ScaleContextShape } from "./ScaleContext" import { round } from "../math" import * as vec from "../vec" -export interface MafsViewProps { +export type MafsViewProps = React.PropsWithChildren<{ width?: number | "auto" height?: number /** Whether to enable panning with the mouse and keyboard */ @@ -32,9 +32,9 @@ export interface MafsViewProps { * Note that server-side rendering complicated graphs can really bloat your HTML. */ ssr?: boolean -} +}> -export const MafsView: React.FC = ({ +export function MafsView({ width: desiredWidth = "auto", height = 500, pan = true, @@ -42,7 +42,7 @@ export const MafsView: React.FC = ({ preserveAspectRatio = "contain", children, ssr = false, -}) => { +}: MafsViewProps) { const [visible, setVisible] = React.useState(ssr ? true : false) const desiredCssWidth = desiredWidth === "auto" ? "100%" : `${desiredWidth}px`