Skip to content

How to make Signals work with Routes #330

@jaydenintusurg

Description

@jaydenintusurg

Hi, does Signal not work with Routes from react-router-dom.

I notice every time I include the import Signal statement (import { useSignal } from '@preact/signals-react';) in a component file where I use Routes. It will throw the error below:

Uncaught Error: [Route] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>

image

import React, { Suspense } from 'react';
import Box1 from './Box1';
import {
  Route, Navigate, Routes,
} from 'react-router-dom';

const SignalsPattern = () => (
       <Routes>
        <Route
          path='/procedure'
          element={(
            <Suspense fallback=''>
              <Box1 />
            </Suspense>
          )}
        />
      </Routes>
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions