How to use the react-redux.useDispatch function in react-redux

To help you get started, we’ve selected a few react-redux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stevenleeg / grooveboat / src / js / pages / room / index.js View on Github external
const DJBar = () => {
  ////
  // Hooks
  //
  const dispatch = useDispatch();
  const room = useSelector(RoomSelectors.currentRoom);
  const activeDjId = room.get('activeDj');
  const peerId = useSelector(BuoySelectors.peerId);

  ////
  // Rendering
  //
  const isDj = room.get('djs').indexOf(peerId) !== -1;

  if (!isDj) {
    return false;
  }

  return (
    <div>
      </div>
github xyfir / illuminsight / components / reader / InsightTool.tsx View on Github external
export function InsightTool(): JSX.Element {
  const { insightsIndex, recipe } = useSelector((s: AppState) =&gt; s);
  const [active, setActive] = React.useState(false);
  const dispatch = useDispatch();
  const classes = useStyles();

  /**
   * Get element to attach insights to.
   */
  function getElement(elements: HTMLElement[]): HTMLElement | undefined {
    // Remove #ast and any ancestors
    elements.splice(
      elements.findIndex((el) =&gt; el.id == 'ast'),
      elements.length,
    );

    // Remove non-ast elements
    elements = elements.filter((el) =&gt; el.getAttribute('ast') !== null);

    // Reverse list so it's [parent,child]
github Waiviogit / waivio / src / client / discoverObjects / DiscoverFiltersSidebar / DiscoverFiltersSidebar.js View on Github external
const DiscoverFiltersSidebar = ({ intl, match, history }) => {
  // redux-store
  const dispatch = useDispatch();
  const wobjects = useSelector(getFilteredObjects);
  const userLocation = useSelector(getUserLocation);
  const filters = useSelector(getAvailableFilters);
  const activeFilters = useSelector(getActiveFilters);
  const hasMap = useSelector(getHasMap);

  if (isEmpty(userLocation)) {
    dispatch(getCoordinates());
  }

  const setSearchArea = map => dispatch(setFiltersAndLoad({ ...activeFilters, map }));

  const handleMapSearchClick = map => {
    setSearchArea(map);
    dispatch(setMapFullscreenMode(false));
  };
github CLOSER-Cohorts / archivist / react / src / components / InstrumentForm.js View on Github external
export const InstrumentForm = (props) => {
  const {instrument, onChange, path, onDelete} = props;

  const dispatch = useDispatch();
  const classes = useStyles();

  const status = ObjectStatus(instrument.id || 'new', 'Instrument')

  const onSubmit = (values) => {
    console.log(values)
    values = ObjectCheckForInitialValues(instrument, values)
    console.log(values)
    if(isNil(instrument.id)){
      dispatch(Instrument.create(values))
    }else{
      dispatch(Instrument.update(instrument.id, values))
    }
  }

  return (
github monjason23 / burger-dash / src / containers / GameModalTimesUp.jsx View on Github external
function GameModalTimesUp(props) {
  const dispatch = useDispatch();

  const [showModal, setShowModal] = useState(false);
  const score = useSelector(state => state.gameStatus.score, shallowEqual);
  const time = useSelector(state => state.gameStatus.time, shallowEqual);

  useEffect(() => {
    if (time === 0) {
      setShowModal(true);
    }
  }, [time, showModal]);

  function handlePlayAgain() {
    setShowModal(false);
    dispatch({
      type: gameConstants.RESTART
    });
github indico / newdle / newdle / client / src / components / answer / MultipleSlot.js View on Github external
export default function MultipleSlot({pos, options}) {
  const dispatch = useDispatch();
  return (
    <div style="{{top:">
      {options.map(option =&gt; (
        <option> dispatch(option.action())} /&gt;
      ))}
    </option></div>
  );
}
github danielgrijalva / overworld / frontend / src / modules / app / components / navbar / index.js View on Github external
const Navbar = ({ history }) =&gt; {
  const [activeItem, setActiveItem] = useState("");
  const { user, isAuthenticated } = useSelector(state =&gt; state.auth);
  const dispatch = useDispatch();

  const handleItemClick = (_e, { name }) =&gt; {
    setActiveItem(name);
    history.push(`/${name}`);
  };

  const handleResultSelect = result =&gt;
    history.push(`/games/${result.slug}`, result.slug);

  return (
    <menu>
      <div>
      
            <img src="/earth.svg" alt="logo"></div></menu>
github bnankiewicz / organic / src / screens / Home.tsx View on Github external
function Home({componentId}: HomeProps) {
  function renderInner(props) {
    return (
      
    );
  }

  const dispatch = useDispatch();
  return 
  return (
    
  );
  return (