
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
mobx-react-helper
Advanced tools
MobX helper library for React component engine, with TypeScript Class & Decorator supports.
MobX helper library for React component engine, with TypeScript Class & Decorator supports.
SemVer | status | ES decorator | MobX |
---|---|---|---|
>=0.4 | ✅developing | stage-3 (internal use) | >=6.11 |
0.3.x | ❌deprecated | stage-3 | >=6.11 |
<0.3 | ❌deprecated | stage-2 | >=4 <6.11 |
npm i mobx react \
mobx-react \
mobx-react-helper
tsconfig.json
Compatible with MobX 6/7:
{
"compilerOptions": {
"target": "ES6",
"moduleResolution": "Node",
"useDefineForClassFields": true,
"experimentalDecorators": false,
"jsx": "react-jsx"
}
}
source/index.tsx
import { createRoot } from 'react-dom/client';
import { MyComponent } from './Component';
import { session, MyContext } from './store';
createRoot(document.body).render(
<MyContext.Provider value={session}>
<MyComponent />
</MyContext.Provider>
);
source/store.ts
import { createContext } from 'react';
export const session = { email: 'tech-query@idea2.app' };
export const MyContext = createContext(session);
source/Component.tsx
import { computed } from 'mobx';
import { observer } from 'mobx-react';
import { ObservedComponent } from 'mobx-react-helper';
import { session } from './store';
export type MyComponentProps = { prefix: string };
type State = { text: string };
@observer
export class MyComponent extends ObservedComponent<
MyComponentProps,
{ email: string },
State
> {
state: Readonly<State> = { text: '' };
@computed
get decoratedText() {
return (
this.observedProps.prefix +
this.observedState.text +
this.observedContext.email
);
}
render() {
return <p>{this.decoratedText}</p>;
}
}
import { observable } from 'mobx';
import { observer } from 'mobx-react';
import { ObservedComponent, reaction } from 'mobx-react-helper';
@observer
export class MyComponent extends ObservedComponent {
@observable
accessor count = 0;
componentDidMount() {
super.componentDidMount();
// Super method call is required if you have more "did mount" logic below
// Your logic is here...
}
componentWillUnmount() {
super.componentWillUnmount();
// Super method call is required if you have more "will unmount" logic below
// Your logic is here...
}
@reaction(({ count }) => count)
handleCountChange(newValue: number, oldValue: number) {
console.log(`Count changed from ${oldValue} to ${newValue}`);
}
render() {
return (
<button onClick={() => this.count++}>Up count {this.count}</button>
);
}
}
import { observer } from 'mobx-react';
import { FormComponent } from 'mobx-react-helper';
@observer
export class MyField extends FormComponent {
render() {
const { onChange, ...props } = this.props,
{ value, handleChange } = this;
return (
<>
<input
{...props}
onChange={({ currentTarget: { value } }) =>
(this.innerValue = value)
}
/>
<output>{value}</output>
</>
);
}
}
FAQs
MobX helper library for React component engine, with TypeScript Class & Decorator supports.
The npm package mobx-react-helper receives a total of 18 weekly downloads. As such, mobx-react-helper popularity was classified as not popular.
We found that mobx-react-helper demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.