Skip to content
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

Parent component re-renders #203

Open
wzl13211 opened this issue Jul 2, 2024 · 1 comment
Open

Parent component re-renders #203

wzl13211 opened this issue Jul 2, 2024 · 1 comment

Comments

@wzl13211
Copy link

wzl13211 commented Jul 2, 2024

Changing one component causes the other component to render, and both components have unrelated state in the repository, but in reality neither of them matters.

@wzl13211
Copy link
Author

wzl13211 commented Jul 2, 2024

`import { Model } from "react-model";

// define model
const Test = {
state: {
items: ["Install react-model", "Read github docs", "Build App"],
sex: "man",
num: 0,
},
actions: {
setNum: () => (state) => {
state.num += 1;
},
},
};

// Model Register
const { useStore } = Model({ Test });
export { useStore };`

import { useStore } from "@/store/TestStore";
const Child = () => {
const [state, actions] = useStore("Test");
console.log("update child");
const handel = async () => {
actions.setNum();
};
return (
<>


{state.num}


</>
);
};

export default Child;

import Child from "./Child";
import { useStore } from "@/store/TestStore";
const Test = () => {
const [state] = useStore("Test");
console.log("update father");
return (


{state.sex}



);
};

export default Test;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant