-
Notifications
You must be signed in to change notification settings - Fork 197
Closed
Description
I have a curious case where I am using classes instead of plain old JS objects as input properties for my components.
Simple usage with classes like the following works as expected and maintains its state when I make changes to styling etc.
import { createElement, useState } from 'react'
export class CounterProps {
constructor(title) {
this.title = title;
}
}
export const Counter = (props) => {
const [count, setCount] = useState(0)
return createElement("div", null,
createElement("h1", null, props.title),
createElement("h1", null, count),
createElement("button", { onClick: () => setCount(count + 1) }, "Increment")
);
}
export const Counters = () => {
return createElement("div", null,
createElement(Counter, new CounterProps("Page title")),
createElement(Counter, new CounterProps("Another title"))
);
}
However, once I extend CounterProps
with anything then fast-refresh doesn't pick up the changes anymore:
export class Anything { }
export class CounterProps extends Anything {
constructor(title) {
super();
this.title = title;
}
}
I am using the following versions (on Windows):
- react-refresh v0.9.0
- @pmmmwh/react-refresh-webpack-plugin v0.4.3
- react v16.14.0
- webpack v4.44.2
fc1943s and brase
Metadata
Metadata
Assignees
Labels
No labels