How to use the react-router-dom.useParams function in react-router-dom

To help you get started, we’ve selected a few react-router-dom 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 flow-typed / flow-typed / definitions / npm / react-router-dom_v5.x.x / flow_v0.104.x- / test_react-router-dom.js View on Github external
it('useParams', () => {
      const params: { [key: string]: ?string, ... } = useParams();
    });
github dvaJi / ReaderFront / src / admin / chapters / Detail / Detail.js View on Github external
function ChapterDetail() {
  const [isModalOpen, toggleModal] = useState(false);
  const { chapterId } = useParams();
  const { formatMessage: f } = useIntl();
  const { loading, error, data } = useQuery(FETCH_CHAPTER, {
    variables: { chapterId: parseInt(chapterId, 0) }
  });

  if (loading) return f({ id: 'loading', defaultMessage: 'Loading...' });
  if (error) return <p id="error_releases">Error :(</p>;

  const langName = languageIdToName(data.chapterById.language);
  const chapterUrl = `${window.location.origin}/${data.chapterById.read_path}`;

  return (
    &lt;&gt;
github jitsucom / jitsu / configurator / frontend / src / ui / pages / SourcesPage / partials / EditSource / EditSource.tsx View on Github external
const EditSource = ({ projectId, sources, setSources, setBreadcrumbs }: CommonSourcePageProps) =&gt; {
  const params = useParams&lt;{ sourceId: string }&gt;();

  const sourceData = useMemo(() =&gt; sources.find((source: SourceData) =&gt; source.sourceId === params.sourceId), [sources, params.sourceId]);

  const connectorSource = useMemo(
    () =&gt; allSources.find((source: SourceConnector) =&gt; snakeCase(source.id) === sourceData?.sourceProtoType) ?? {} as SourceConnector,
    [sourceData?.sourceProtoType]
  );

  useEffect(() =&gt; {
    setBreadcrumbs(withHome({
      elements: [
        { title: 'Sources', link: routes.root },
        {
          title: 
        }
      ]
github penta-jelly / re-radio / client / src / modules / station / header / index.tsx View on Github external
export const Header: React.FC = props =&gt; {
  const classes = useStyles();
  const params = useParams();
  const { data, error } = useStationQuery({ variables: { slug: params.slug } });

  const content = React.useMemo(() =&gt; {
    if (data) {
      return (
        &lt;&gt;
          {data.station.name} - Online users: {data.station.onlineUserIds.length}
        
      );
    } else if (error) {
      return error.message;
    }
    return ;
  }, [data, error]);

  return (
github AugurProject / augur / packages / orbit-web / src / containers / ChannelHeader.js View on Github external
function ChannelHeader () {
  const location = useLocation()
  const { channel } = useParams()
  const { networkStore, uiStore } = useContext(RootContext)
  const [t] = useTranslation()

  function handleMenuButtonClick (e) {
    e.stopPropagation()
    uiStore.openControlPanel()
  }

  const overrideName = t(`viewNames.${location.pathname.slice(1)}`)

  return useObserver(() =&gt; (
    <div>
      <div></div></div>
github HandshakeAlliance / HNScan / src / screens / Block.js View on Github external
export default function Block() {
  const page = usePage();
  const { height } = useParams();
  return (
    &lt;&gt;
      }&gt;
        
      
    
  );
}
github ohsu-comp-bio / funnel / webdash / src / Pages.js View on Github external
function Task() {
  let { task_id } = useParams();
  const [task, setTask] = React.useState({});
  //const [task, setTask] = React.useState(example_task);
  
  React.useEffect(() =&gt; {
    var url = new URL("/v1/tasks/" + task_id, window.location.origin);
    get(url).then(
      (task) =&gt; {
        setTask(task);
      });
  }, [task_id]);

  const json = (
github snphq / react-starter-boilerplate / src / pages / UserInfo / UserCard / UserCardContainer.jsx View on Github external
const UserСardContainer = () =&gt; {
  const params = useParams();
  const userId = Number(params.id);

  const onFetchUser = useAction(fetchUserAction.type);
  const user = useSelector(userSelector, userId);
  const fetching = useSelector(isFetchingSelector);

  useEffect(() =&gt; {
    onFetchUser({ id: userId });
  }, [onFetchUser, userId]);

  return ;
};
github sebastienbarbier / seven23_webapp / src / app / components / nomadlist / CityDetails.js View on Github external
export default function CityStats({ statistics, isLoading, setTitle }) {
  const dispatch = useDispatch();
  const classes = useStyles();

  const account = useSelector(state => state.account);
  const [categoriesToExclude, setCategoriesToExclude] = useState(() =>
    account.preferences && account.preferences.nomadlist
      ? account.preferences.nomadlist
      : []
  );

  let { slug } = useParams();

  const [city, setCity] = useState(null);

  useEffect(() => {
    if (statistics) {
      const c = statistics.cities.find(c => c.place_slug == slug);
      setCity(c);
      setTitle(c.place);
    }
  }, [slug, statistics]);

  const selectedCurrency = useSelector(state =>
    state.account
      ? state.currencies.find(c => c.id === state.account.currency)
      : null
  );