Skip to content

Instantly share code, notes, and snippets.

View sseletskyy's full-sized avatar
🍊
FP mood

Sergiy Seletskyy sseletskyy

🍊
FP mood
View GitHub Profile
@sseletskyy
sseletskyy / index.ts
Created December 1, 2023 10:35
Typescript ModifyProps
type OriginalType = {
prop1: string;
prop2: number;
prop3: boolean;
};
type ModifyProp<Type, Key extends keyof Type, Value> = Omit<Type, Key> & {
[K in Key]: Value;
};
@sseletskyy
sseletskyy / react-suspense-api-example.jsx
Created December 12, 2021 19:19
react-suspense-api-example.jsx
/**
* First issue I see is the way how useEffect is defined
* The dependency list should not contain `setData`, but only `userId`
*
* The second issue is that there is no need to use `useEffect`
* in case the React component is using Suspense API
* So we can get rid of `useEffect` and `useState` as well.
* Instead we should call `fetchUserProfile` and pass the result to the child component.
* And also we can define `fallback` prop
*
@sseletskyy
sseletskyy / machine.js
Last active September 19, 2021 19:49
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'modalWindow',
initial: 'hidden',
context: {
submitDisabled: true,
closeDisabled: false,
},
states: {
hidden: {
export function mockFetchSuccess(data) {
return jest.fn().mockImplementation(() =>
Promise.resolve({
ok: true,
json: () => data,
})
);
}
export function mockFetchFail(reason) {
return jest.fn().mockImplementation(() => Promise.reject(reason));
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@sseletskyy
sseletskyy / machine.js
Last active June 21, 2021 19:40
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'investor',
initial: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
@sseletskyy
sseletskyy / git-tag-delete-local-and-remote.sh
Created August 5, 2020 11:31 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@sseletskyy
sseletskyy / browser.scss
Created July 31, 2020 15:34
browser only mixins
@mixin ie11 {
/* stylelint-disable */
_:-ms-input-placeholder,
/* stylelint-enable */
:root & {
@content;
}
}
// Safari 10.1+
@sseletskyy
sseletskyy / browser.scss
Created July 31, 2020 15:34
browser only mixins
@mixin ie11 {
/* stylelint-disable */
_:-ms-input-placeholder,
/* stylelint-enable */
:root & {
@content;
}
}
// Safari 10.1+
@sseletskyy
sseletskyy / index.css
Last active June 23, 2020 14:24
Universal hover/active effect for the button
.link {
height: 36px;
line-height: 36px;
display: inline-block;
/* position: relative is required for :after to work correctly */
position: relative;
background-color: white;
color: black;
border: 1px solid gray;
}