Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const Count: React.FunctionComponent = () => {
const store = useObservable({ count: 0 });
return (
<>
{() => <h3>Current count (from MobX): {store.count}</h3>}
<button> store.count++}>Increment</button>
<button> (store.count = 0)}>Reset</button>
);
};
function InjectStoreContext({ children, initialData }) {
let timerInterval = null
store = useObservable(initializeData(initialData))
start = useCallback(
action(() => {
timerInterval = setInterval(() => {
store.lastUpdate = Date.now()
store.light = true
}, 1000)
})
)
stop = () => {
if (timerInterval) {
clearInterval(timerInterval)
}
}
const BuDeJie = observer(function(props: Props) {
const { navigation, type } = props;
const buDeJieMobx = useObservable(new BuDeJieMobx());
const { largeListData, maxtime = '', fetchBuDeJieData } = buDeJieMobx;
const waterfallRef: WaterfallList = useRef();
const customOverlayRef: Overlay = useRef();
useEffect(() => {
fetchBuDeJieData(type, '');
}, []);
function picturePress(item: Picture, props: Props) {
if (item.isLongPicture || !item.is_gif) {
navigation.navigate('WebView', { uri: item.weixin_url });
} else {
const height = isIPhoneX ? SCREEN_HEIGHT - 44 - 49 : SCREEN_HEIGHT;
const RenderControls = observer(() => {
let store = getStore();
let state = useObservable({
maxSampleCount: store.currentMaxSampleCount,
setMaxSampleCount(val) {
state.maxSampleCount = val;
}
});
reaction(
() => store.currentMaxSampleCount,
c => state.setMaxSampleCount(c)
);
return (
<div>
<form> {
e.preventDefault(); </form></div>
const App = observer(() => {
const store = useObservable({
todos: [
{ id: 1, text: 'Buy eggs', completed: true },
{ id: 2, text: 'Write a post', completed: false }
],
toggleTodo(index) {
store.todos[index].completed = !store.todos[index]
.completed;
store.todos = JSON.parse(JSON.stringify(store.todos));
},
get getTodos() {
return store.todos;
},
get getCompletedLen() {
return store.todos.filter(t => t.completed).length;
}
})