Skip to content
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
3 changes: 3 additions & 0 deletions demo/vite.config.demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ export default defineConfig({
plugins: [
react(),
],
define: {
__REACT_SHARED_STATES_DEV__: process.env.NODE_ENV === 'development' ? 'true' : 'false',
}
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-shared-states",
"version": "1.0.5",
"version": "1.0.6",
"type": "module",
"description": "Global state made as simple as useState, with zero config, built-in async caching, and automatic scoping.",
"keywords": [
Expand Down
6 changes: 6 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export let isDevMode = false;

// noinspection JSUnusedGlobalSymbols
export const setDevMode = (value: boolean) => {
isDevMode = value;
};
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./context";
export * from "./hooks";
export * from "./types";
export * from "./types";
export * from "./config";
3 changes: 2 additions & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type {NonEmptyString} from "../types";
import {isDevMode} from "../config";

export const log = (...args: any[]) => {
if (process.env.NODE_ENV !== 'development') return;
if ((typeof __REACT_SHARED_STATES_DEV__ === "undefined" || !__REACT_SHARED_STATES_DEV__) && !isDevMode) return;
console.log(
'%c[react-shared-states]',
'color: #007acc; font-weight: bold',
Expand Down
3 changes: 3 additions & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// <reference types="vite/client" />

declare const __REACT_SHARED_STATES_DEV__ : boolean;
5 changes: 4 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ export default defineConfig({
exclude: ['node_modules', 'dist'], // Exclude unnecessary files
})

]
],
define: {
__REACT_SHARED_STATES_DEV__: process.env.NODE_ENV === 'development' ? 'true' : 'false',
}
});