Code Monkey home page Code Monkey logo

resso's Introduction

Hi there, I'm 南小北 👋

  • 🍭 Find fun on my site lee.so
  • 🌱 Follow me on Twitter or Instagram
  • 🗞 Read stories since 2008 on my blog
  • 📔 Read FE tech articles on my Retalk
  • 💯 Get your web design done on 21beats
  • 🧭 Checkout slides(PPT) about FE on slides
  • 😇 Talk to me via Email

A designer, a writer, a front-end developer. with React ⚛️ and Vue ♻️ skills.

Love simple things and make things simple ❤️. especially, I make simple React libraries, I contribute to make the React ⚡️ world simpler, not complexity and chaos 🗡.


Repos:

resso's People

Contributors

himself65 avatar nanxiaobei avatar tyleratcodeoflife avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

resso's Issues

orbs: android: circleci/[email protected] node: circleci/[email protected] jobs: test-fastlane: docker: - image: cimg/android:2022.07 auth: username: mydockerhub-user password: $DOCKERHUB_PASSWORD # context / project UI env-var reference resource_class: large steps: - checkout - node/install: install-yarn: false node-version: "16.13.0" - run: npm install - android/decode-keystore: keystore-location: android/app/keystore - android/create-keystore-properties: working-directory: android - android/create-google-play-key: working-directory: android - android/fastlane-deploy: working-directory: android lane-name: internal

limitation of resso

I found below snippet would not work:

import { useState } from 'react';
import resso from 'resso';

// 🪢 resso
// https://github.com/nanxiaobei/resso

const store = resso({
  count: 0,
  text: 'hello',
  inc: () => store.count++,
});

function App() {
  const [i, setI] = useState(0);

  if (i % 2 === 1) {
    return <div>i === {i}</div>;
  }

  return (
    <>
      <div>{store.count}</div>
      <button
        onClick={() => {
          store.inc();
          setI(i + 1);
        }}
      >
        inc
      </button>
    </>
  );
}

export default App;

Check codesandbox.

It will cause the error Rendered fewer hooks than expected. This may be caused by an accidental early return statement.

We can change it a little bit as below:

import { useState } from 'react';
import resso from 'resso';

// 🪢 resso
// https://github.com/nanxiaobei/resso

const store = resso({
  count: 0,
  text: 'hello',
  inc: () => store.count++,
});

function App() {
  const { count } = store;
  const [i, setI] = useState(0);

  if (i % 2 === 1) {
    return <div>i === {i}</div>;
  }

  return (
    <>
      <div>{count}</div>
      <button
        onClick={() => {
          store.inc();
          setI(i + 1);
        }}
      >
        inc
      </button>
    </>
  );
}

export default App;

The user should eject the value from store before any of condition statement.

I suggest to put such info as notice/usage-limitation in readmd, so that users are able to avoid such issue

不能在函数内部使用this

demo里给的示例是这样的:

const store = resso({
  user: {
    info: {
      count: 0,
    }
  },
  inc: () => store.user.info.count++,
});

我尝试下面的写法,却不能正常运行:

const store = resso({
      count: 0,
  },
  inc(){ this.count++}
});

会报错:TypeError: Cannot set properties of undefined (setting 'count')

this 未定义

功能需求,建议添加一个 reset 方法

pinia 的 $reset 方法很好用的, 建议添加 reset 方法, 所有值返回到初始状态。

使用场景:
某些模块功能比较复杂,使用了 独立的 store, 所有子组件共享状态,当用户切换到其它模块后再次切换回来时,希望状态值回到初始化值。目前通过定义 store的时候,再写一个initStore来处理,实现起来比较繁琐,如果内部能实现就更好了。
image

hook数量不一致疑问

大佬这个库确实大道至简,非常棒!
但是这个用provy代理get,实际上是执行一个hook,开发者不会把它当成是hook去注意,可能会不经意间放到条件语句里面,导致错误
image
就像这种情况,感觉有点美中不足😂

Nested objects?

Hey,

First of all great job :)

just have a question about nested object like this one:

const store = resso({
  user: {
    info: {
      count: 0,
    }
  },
  inc: () => store.user.info.count++,
});

function Control() {
  const { inc } = store;
  return (
    <>
      <p>{store.user.info.count}</p>
      <button onClick={inc}>-</button>
    </>
  );
}

Maybe this line https://github.com/nanxiaobei/resso/blob/main/src/index.ts#L31 should be some recursive function?
I'm not so good so ... I don't have any PR or suggestions ... just try to learn :) Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.