diff --git a/.changeset/nervous-singers-reply.md b/.changeset/nervous-singers-reply.md new file mode 100644 index 0000000000..ee5b7043c1 --- /dev/null +++ b/.changeset/nervous-singers-reply.md @@ -0,0 +1,6 @@ +--- +"@khanacademy/perseus": patch +"@khanacademy/perseus-editor": patch +--- + +Remove unused handling of deprecated Interactive Graph prop diff --git a/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx b/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx index fa4f5939dc..debb8ded2b 100644 --- a/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx +++ b/packages/perseus-editor/src/widgets/interactive-graph-editor.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/no-unsafe */ import {vector as kvector} from "@khanacademy/kmath"; import { components, @@ -37,7 +36,6 @@ import type {PropsFor} from "@khanacademy/wonder-blocks-core"; const {InfoTip} = components; const {containerSizeClass, getInteractiveBoxFromSizeClass} = SizingUtils; -const DeprecationMixin = Util.DeprecationMixin; const InteractiveGraph = InteractiveGraphWidget.widget; type InteractiveGraphProps = PropsFor; @@ -46,12 +44,6 @@ const defaultBackgroundImage = { url: null, } as const; -const deprecatedProps = { - showGraph: function (props) { - return {markings: props.showGraph ? "graph" : "none"}; - }, -} as const; - const POLYGON_SIDES = _.map(_.range(3, 13), function (value) { return ( { }, }; - // TODO(jack): Use versioning instead of DeprecationMixin - deprecatedProps = deprecatedProps; - - // TODO(jangmi, CP-3288): Remove usage of `UNSAFE_componentWillMount` - UNSAFE_componentWillMount() { - DeprecationMixin.UNSAFE_componentWillMount.call(this); - } - changeMatchType = (newValue) => { const correct = { ...this.props.correct, diff --git a/packages/perseus/src/util.ts b/packages/perseus/src/util.ts index bc5408e2d2..163ea42175 100644 --- a/packages/perseus/src/util.ts +++ b/packages/perseus/src/util.ts @@ -529,51 +529,6 @@ function constrainedTickStepsFromTickSteps( ]; } -/** - * Transparently update deprecated props so that the code to deal - * with them only lives in one place: (Widget).deprecatedProps - * - * For example, if a boolean `foo` was deprecated in favor of a - * number 'bar': - * deprecatedProps: { - * foo: function(props) { - * return {bar: props.foo ? 1 : 0}; - * } - * } - */ -const DeprecationMixin: any = { - // This lifecycle stage is only called before first render - // TODO(jangmi, CP-3288): Remove usage of `UNSAFE_componentWillMount` - UNSAFE_componentWillMount: function () { - const newProps: Record = {}; - - _.each( - this.deprecatedProps, - function (func, prop) { - // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. - if (_.has(this.props, prop)) { - // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. - _.extend(newProps, func(this.props)); - } - }, - this, - ); - - if (!_.isEmpty(newProps)) { - // Set new props directly so that widget renders correctly - // when it first mounts, even though these will be overwritten - // almost immediately afterwards... - _.extend(this.props, newProps); - - // ...when we propagate the new props upwards and they come - // back down again. - // TODO(jeff, CP-3128): Use Wonder Blocks Timing API - // eslint-disable-next-line no-restricted-syntax - setTimeout(this.props.onChange, 0, newProps); - } - }, -}; - /** * Approximate equality on numbers and primitives. */ @@ -963,7 +918,6 @@ const Util = { gridStepFromTickStep, tickStepFromNumTicks, constrainedTickStepsFromTickSteps, - DeprecationMixin, eq, deepEq, parseQueryString, diff --git a/packages/perseus/src/widgets/interactive-graph.tsx b/packages/perseus/src/widgets/interactive-graph.tsx index 8dbae8bd1c..ebbc4df794 100644 --- a/packages/perseus/src/widgets/interactive-graph.tsx +++ b/packages/perseus/src/widgets/interactive-graph.tsx @@ -56,8 +56,6 @@ import type { SineCoefficient, } from "../util/geometry"; -const {DeprecationMixin} = Util; - const TRASH_ICON_URI = "https://ka-perseus-graphie.s3.amazonaws.com/b1452c0d79fd0f7ff4c3af9488474a0a0decb361.png"; @@ -93,12 +91,6 @@ function numSteps(range: Range, step: number) { return Math.floor((range[1] - range[0]) / step); } -const deprecatedProps = { - showGraph: function (props) { - return {markings: props.showGraph ? "graph" : "none"}; - }, -} as const; - const _getShouldShowInstructions: (arg1: Props) => boolean = (props) => { return ( _isClickToAddPoints(props) && @@ -190,11 +182,6 @@ class LegacyInteractiveGraph extends React.Component { shouldShowInstructions: _getShouldShowInstructions(this.props), }; - // TODO(jangmi, CP-3288): Remove usage of `UNSAFE_componentWillMount` - UNSAFE_componentWillMount() { - DeprecationMixin.UNSAFE_componentWillMount.call(this); - } - componentDidMount() { if (this.refs.graph) { // eslint-disable-next-line react/no-string-refs @@ -264,8 +251,6 @@ class LegacyInteractiveGraph extends React.Component { ); }; - deprecatedProps: any = deprecatedProps; - setGraphie: (arg1: any) => void = (newGraphie) => { this.graphie = newGraphie; this.setupGraphie();