![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
A Lens-like interface for state management in React.
stateful<S>(initialState: S): [Lens<S>, MutableRefObject<S>]
stateless<S>(): [Lens<S>, LensProvider<S>]
useStateful<S>(initialState: S): [Lens<S>, MutableRefObject<S>]
The React equivalent of stateful
as it is convenient to create a stateful lens as part of initializing a component.
Note: There is no useStateless
because the return value of stateless
is static and can just be constructed outside the React life-cycle.
LensProvider<S>
Lens<A>
A stateless Proxy around A
Lens<A>.use(shouldUpdate? ShouldUpdate<A>): [ProxyValue<A>, UpdateFn<A>]
Lens<A>.$key
Use shouldUpdate.
If do use a shouldUpdate argument for the lens, you can either memoize it with React.useMemo
or React.useCallback
or store it outside
of the component.
Uses TypeScript and Proxy to dynamically construct a lens-like interface for your application state.
You can construct a lens/React Provider by just providing the shape of your application state
// LensProvider.ts
import { stateless } from "concave";
import type { State } from "./application-state";
export const [lens, LensProvider] = stateless<State>();
// App.tsx
import type { State } from './application-state';
import { Root } from './Root';
import { lens, LensProvider } from './LensProvider';
export const App = () => {
const state: State = { ... };
<LensProvider value={state} onChange={...}>
<Root state={lens} />
</LensProvider>
}
The lens can be focused by regular member access.
// Root.tsx
import { Lens } from "concave";
import type { State } from "./application-state";
import { Profile } from "./Profile";
type Props = {
state: Lens<State>;
};
export const Root = (props: Props) => {
return <Profile state={props.state.user.profile} />;
};
And then the underlying data it can be accessed by collapsing the lens into a React hook with use
.
// Profile.tsx
import { Lens } from "concave";
type Props = {
state: Lens<{ name: string; email: string }>;
};
const Profile = (props: Props) => {
const [name, updateProfileName] = props.state.name.use();
const [email, updateProfileEmail] = props.state.email.use();
return (
<>
<input type="text" value={name} onChange={(ev) => updateProfileName(() => ev.target.value)} />
<input type="email" value={email} onChange={(ev) => updateProfileEmail(() => ev.target.value)} />
</>
);
};
FAQs
Lens-like state management (for React)
The npm package concave receives a total of 2 weekly downloads. As such, concave popularity was classified as not popular.
We found that concave demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.