This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| paths: | |
| - "apps/your-app/**" | |
| - "packages/**" | |
| - ".github/workflows/test.yml" | |
| workflow_dispatch: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const [counter, setCounter] = useState(0) | |
| const handleIncrement = () => { | |
| setCounter(prev => prev + 1) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const store = { | |
| state: { | |
| posts: [] | |
| }, | |
| mutations: { | |
| POSTS_SET(state, data) { | |
| state.posts = data | |
| } | |
| }, | |
| actions: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState } from 'react'; | |
| const Form = () => { | |
| const [name, setName] = useState(''); | |
| const handleChange = e => { | |
| setName(e.target.value); | |
| } | |
| const handleSubmit = e => { |
NewerOlder