import React from 'react'
import { Link } from 'react-router-dom'
import { linkStateWithAppReturn } from '../utils/navReturnContext'

/** Router-Link mit appReturn im State (Rücksprung vom Zielscreen). */
export default function NavStateLink({ to, returnContext, state, children, ...rest }) {
  return (
    <Link to={to} state={linkStateWithAppReturn(returnContext, state)} {...rest}>
      {children}
    </Link>
  )
}
