Skip to content

Resolve unmounting instance issue #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions config/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ module.exports = {
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
"plugin:react-hooks/recommended",
"plugin:react/recommended"
],
parser: "@typescript-eslint/parser",
parserOptions: {
Expand All @@ -17,20 +18,20 @@ module.exports = {
ecmaVersion: 12,
sourceType: "module"
},
plugins: ["prettier", "react", "@typescript-eslint", "simple-import-sort"],
plugins: ["@typescript-eslint", "prettier", "react", "simple-import-sort"],
overrides: [
{
files: [".js", ".jsx", ".ts", ".tsx"]
}
],
rules: {
indent: ["error", 2],
"@typescript-eslint/no-explicit-any": "off",
"linebreak-style": ["error", "unix"],
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error",
indent: ["error", 2],
quotes: ["error", "double"],
semi: ["error", "always"],
"@typescript-eslint/no-explicit-any": "off"
semi: ["error", "always"]
},
settings: {
react: {
Expand Down
26 changes: 20 additions & 6 deletions example/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ import * as torus from "./sketches/torus";
import "./example.css";

function App() {
const [state, setState] = useState({ rotation: 160, sketch: box.sketch });
const [state, setState] = useState({
rotation: 160,
sketch: box.sketch,
unmount: false
});

return (
<>
<ReactP5Wrapper sketch={state.sketch} rotation={state.rotation} />
{state.unmount ? (
<p>Unmounted the sketch</p>
) : (
<ReactP5Wrapper sketch={state.sketch} rotation={state.rotation} />
)}
<input
type="range"
defaultValue={state.rotation}
Expand All @@ -27,14 +35,20 @@ function App() {
<button
onClick={() => {
const useTorus = state.sketch === box.sketch;
setState({
...state,
sketch: useTorus ? torus.sketch : box.sketch
});
setState({ ...state, sketch: useTorus ? torus.sketch : box.sketch });
}}
>
Change Sketch
</button>
{state.unmount ? (
<button onClick={() => setState({ ...state, unmount: false })}>
Remount
</button>
) : (
<button onClick={() => setState({ ...state, unmount: true })}>
Unmount
</button>
)}
</>
);
}
Expand Down
Loading