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

module-first setup #14

Merged
merged 3 commits into from
Apr 26, 2024
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
2 changes: 1 addition & 1 deletion .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"buildCommand": "compile",
"sandboxes": ["new", "react-typescript-react-ts"],
"node": "14"
"node": "18"
}
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

39 changes: 39 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint-env node */
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
'prettier',
],
ignorePatterns: ['dist/'],
settings: {
'import/resolver': {
typescript: true,
},
react: { version: 'detect' },
},
rules: {
'import/no-unresolved': ['error', { ignore: ['zustand-signal'] }],
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
};
64 changes: 0 additions & 64 deletions .eslintrc.json

This file was deleted.

14 changes: 10 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: DerYeger/pnpm-setup-action@master
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8.2.0
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
- run: npm test
- run: npm run compile
- run: |
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
npm publish
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: DerYeger/pnpm-setup-action@master
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8.2.0
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
- run: npm test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
*.swp
node_modules
/dist
/jsx-runtime.d.ts
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/pnpm-lock.yaml
/dist
4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,68 @@

## [Unreleased]

### Changed

- Module-first setup #14

## [0.5.3] - 2023-02-26

### Changed

- fix(jsx-runtime): revert jsxDEV #12

## [0.5.2] - 2023-02-25

### Changed

- update create-react-signals #11

## [0.5.1] - 2023-01-25

### Changed

- use react-create-signals v0.6.2

## [0.5.0] - 2023-01-21

### Changed

- fix: improve types #7
- feat: fallback to redenerer and scoped subscription #8

## [0.4.1] - 2023-01-13

### Changed

- use react-create-signals v0.4.1 #6

## [0.4.0] - 2023-01-13

### Changed

- feat: uncontrolled when possible #4
- use react-create-signals v0.4.0 #5

## [0.3.0] - 2023-01-09

### Changed

- feat: value prop in signal #3

## [0.2.1] - 2023-01-09

### Changed

- fix: updating arrays #2

## [0.2.0] - 2023-01-09

### Changed

- Use create react signals #1

## [0.1.0] - 2023-01-02

### Added

- Initial release
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zustand-signal

[![CI](https://img.shields.io/github/actions/workflow/status/dai-shi/zustand-signal/ci.yml?branch=main)](https://github.com/dai-shi/zustand-signal/actions?query=workflow%3ACI)
[![CI](https://img.shields.io/github/actions/workflow/status/zustandjs/zustand-signal/ci.yml?branch=main)](https://github.com/zustandjs/zustand-signal/actions?query=workflow%3ACI)
[![npm](https://img.shields.io/npm/v/zustand-signal)](https://www.npmjs.com/package/zustand-signal)
[![size](https://img.shields.io/bundlephobia/minzip/zustand-signal)](https://bundlephobia.com/result?p=zustand-signal)
[![discord](https://img.shields.io/discord/627656437971288081)](https://discord.gg/MrQdmzd)
Expand All @@ -10,10 +10,10 @@ Another React binding for Zustand
## What it is

Typically, Zustand store is a React hook you can just use in React.
There's alternative library called [use-zustand](https://github.com/dai-shi/use-zustand).
There's alternative library called [use-zustand](https://github.com/zustandjs/use-zustand).

This library provides yet another method.
It follows [jotai-signal](https://github.com/jotai-labs/jotai-signal),
It follows [jotai-signal](https://github.com/jotaijs/jotai-signal),
which is inspired by [@preact/signals-react](https://www.npmjs.com/package/@preact/signals-react).

It allows to use the Zustand store in React without using hooks.
Expand All @@ -36,11 +36,7 @@ setInterval(() => {
store.getState().inc();
}, 100);

const Counter = () => (
<div>
Count: {$(store).count}
</div>
);
const Counter = () => <div>Count: {$(store).count}</div>;
```

## How it works
Expand Down Expand Up @@ -80,7 +76,7 @@ const Counter = () => {
}, []);
return (
<div>
{useMemo(() => 'Count: '), []}
{useMemo(() => 'Count: ', [])}
{store.getState().count}
{useMemo(() => ` (${Math.random()})`, [])}
</div>
Expand Down
9 changes: 0 additions & 9 deletions __tests__/01_basic_spec.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "zustand-signal-example",
"version": "0.1.0",
"name": "example",
"version": "0.0.0",
"private": true,
"type": "commonjs",
"dependencies": {
"@types/react": "latest",
"@types/react-dom": "latest",
Expand All @@ -17,11 +18,5 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>zustand-signal example</title>
<title>example</title>
</head>
<body>
<div id="app"></div>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

import App from './App';
import App from './app';

const ele = document.getElementById('app');
if (ele) {
Expand Down
6 changes: 0 additions & 6 deletions examples/01_typescript/tsconfig.json

This file was deleted.

13 changes: 4 additions & 9 deletions examples/02_props/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "zustand-signal-example",
"version": "0.1.0",
"name": "example",
"version": "0.0.0",
"private": true,
"type": "commonjs",
"dependencies": {
"@types/react": "latest",
"@types/react-dom": "latest",
Expand All @@ -17,11 +18,5 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
}
2 changes: 1 addition & 1 deletion examples/02_props/public/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>zustand-signal example</title>
<title>example</title>
</head>
<body>
<div id="app"></div>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/02_props/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

import App from './App';
import App from './app';

const ele = document.getElementById('app');
if (ele) {
Expand Down
6 changes: 0 additions & 6 deletions examples/02_props/tsconfig.json

This file was deleted.

Loading
Loading