Skip to content

Instantly share code, notes, and snippets.

@tejendra
tejendra / items.tests.js
Created September 30, 2021 16:22
How to clear RTK Query cache in tests between requests when using Mock Service Worker and Jest
import React from 'react';
import { rest } from 'msw';
import userEvent from '@testing-library/user-event';
import { render, screen } from '../testUtils';
import ItemsPage from '../pages/Items';
import server from '../mocks/server';
describe('given Items Page', () => {
test('fetches items from API on page load', async () => {
render(<ItemsPage />);
@tejendra
tejendra / MainComponent.js
Created August 27, 2018 16:35
React Native: How to communicate between header and component
import React, { Component } from 'react';
import { DetailScreen, ThirdScreen } from '../screenNames';
import Button from 'react-native-button';
import {
Text, View, ActivityIndicator
} from 'react-native';
export default class MainComponent extends Component {
static navigationOptions = ({ navigation }) => {
const { params = {} } = navigation.state;