microstates / react Goto Github PK
View Code? Open in Web Editor NEW@microstates/react - Microstates in React.js
Home Page: https://codesandbox.io/s/github/microstates/todomvc/tree/master/sandboxes/react
@microstates/react - Microstates in React.js
Home Page: https://codesandbox.io/s/github/microstates/todomvc/tree/master/sandboxes/react
I noticed this today while building a sample app with microstates. I have a TodoState type that looks like:
class TodoState {
todos = [Todo];
count = Number;
I think have a method that adds a todo to the list. In my methdo I am trying to
const inc = model => {
model.count.increment();
model.posts.push({ id: Date.now() });
};
In the above code, the increment never happens, but the push WILL happen.
Here's a code sandbox of what I'm trying to do. If you flip lines 17 and 18, the increment will work.
https://codesandbox.io/s/13yv7ojlkl
I think we are at 0.10.x now.
It's the right thing to do.
I have a TodoState here, trying to initialize the todos prop like below.
export class TodoState {
todos = [Todo];
count = Number;
initialize({ todos, count } = {}) {
let initialized = this;
initialized.todos.set([
{
id: Date.now(),
text: "Initial Todo",
complete: false
}
]);
initialized.count.set(1);
return initialized;
}
}
...
<State type={TodoState} ....></State>
I've even tried initialized.todos.push(...)
, but same Maximum call stack error. Am I doing something wrong here?
Before #1, the tests in this package ran against dist
files. This is the same setup that we have in microstates
repository. It allows us to catch any module export changes that could cause a problem in the package. For the sake of consistency, let's restore this functionality.
To make this work you have to run build before each test module by setting the globalSetup
and moduleNameMapper
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.