Skip to content

Instantly share code, notes, and snippets.

View DJanoskova's full-sized avatar
🐱

Dana Janoskova DJanoskova

🐱
View GitHub Profile
import React, { useState, useEffect } from 'react'
import { fetchUserAction } from '../api/actions.js'
const UserContainer = () => {
const [user, setUser] = useState(null);
const handleUserFetch = async () => {
const result = await fetchUserAction();
setUser(result);
import React, { useState, useEffect, useCalllback } from 'react'
import { fetchUserAction } from '../api/actions.js'
const UserContainer = () => {
const [user, setUser] = useState(null);
const handleUserFetch = useCalllback(async () => {
const result = await fetchUserAction();
setUser(result);
const store = {
state: {
posts: []
},
mutations: {
POSTS_SET(state, data) {
state.posts = data
}
},
actions: {
import React from 'react';
import ReactDOM from 'react-dom';
import { withStore } from 'vuex-but-for-react';
import App from './App';
import store from './store';
const AppWithStore = withStore(App, store);
ReactDOM.render(
const [counter, setCounter] = useState(0)
const handleIncrement = () => {
setCounter(prev => prev + 1)
}
import { useEffect } from 'react';
import { useGetter } from 'vuex-but-for-react';
const PostsPage = () => {
const posts = useGetter('posts');
return (
<ul>
{posts.map(post => (
<li key={post.id}>{post.title}</li>
import React, {FunctionComponent, useRef, useState} from 'react';
import clsx from "clsx";
type ContentEditableProps = {
onClick?: () => void;
onClose?: () => void;
onCancel?: () => void;
onUpdate?: (value: string) => void;
value?: string | number;
className?: string;
@DJanoskova
DJanoskova / test.yml
Created March 31, 2023 13:34
Cypress GitHub workflow for a pnpm monorepo with multiple apps
name: CI
on:
push:
paths:
- "apps/your-app/**"
- "packages/**"
- ".github/workflows/test.yml"
workflow_dispatch: {}
@DJanoskova
DJanoskova / useScrollToTop.ts
Created May 8, 2023 20:15
Provide a FlatList ref to listen to route param change and scroll to the list's top
import {RouteProp, useRoute} from '@react-navigation/native';
import {RefObject, useEffect} from 'react';
import {FlatList} from 'react-native';
export const useScrollToTop = <T extends RouteProp<any>>(
listRef: RefObject<FlatList>,
) => {
const route = useRoute<T>();
useEffect(() => {