Skip to content

Commit

Permalink
Fix types for React 18 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenpetryk committed Jan 5, 2023
1 parent f1cf97c commit 8a55ddd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/display/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ 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
attachDistance?: number
size?: number
color?: string
svgTextProps?: React.SVGAttributes<SVGTextElement>
}
}>

export const Text: React.FC<TextProps> = ({
export function Text({
children,
x,
y,
Expand All @@ -24,7 +24,7 @@ export const Text: React.FC<TextProps> = ({
svgTextProps = {},
attach,
attachDistance = 0,
}) => {
}: TextProps) {
const { pixelMatrix } = useScaleContext()
const transformContext = useTransformContext()

Expand Down
8 changes: 4 additions & 4 deletions src/view/MafsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -32,17 +32,17 @@ export interface MafsViewProps {
* Note that server-side rendering complicated graphs can really bloat your HTML.
*/
ssr?: boolean
}
}>

export const MafsView: React.FC<MafsViewProps> = ({
export function MafsView({
width: desiredWidth = "auto",
height = 500,
pan = true,
viewBox = { x: [-3, 3], y: [-3, 3] },
preserveAspectRatio = "contain",
children,
ssr = false,
}) => {
}: MafsViewProps) {
const [visible, setVisible] = React.useState(ssr ? true : false)
const desiredCssWidth = desiredWidth === "auto" ? "100%" : `${desiredWidth}px`

Expand Down

1 comment on commit 8a55ddd

@vercel
Copy link

@vercel vercel bot commented on 8a55ddd Jan 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.