Reactjs 将对象传递到路线

Reactjs 将对象传递到路线,reactjs,react-router-dom,Reactjs,React Router Dom,我在“app.js”文件中设置了我的应用程序,我在render方法中定义了我的路由器 <HashRouter> <StatusToast /> <Switch> <Route exact={true} path="/" render={pro

我在“app.js”文件中设置了我的应用程序,我在render方法中定义了我的路由器

        <HashRouter>
            <StatusToast />
            <Switch>
                <Route
                    exact={true}
                    path="/"
                    render={props => (
                        <ImageScene{...props} title="Images & Information Search" />
                    )}
                />
                <Route path="/case/:id/images" component={DetailsScene} />
            </Switch>
        </HashRouter>
然后设置路线,如:

const object = getSelectedRow();

<Route path="/case/:id/images" 
       render={props => (<DetailsScene{...props} title={object.title} />
       )} 
/>
const object=getSelectedRow();
(
)} 
/>

但我不能让它工作。。。任何帮助都将是graet,我对react和整个路由器都是全新的。

您可以将状态添加到history.push(),它可用于呈现组件(DetailsScene)。记住用路由器(…)包装DetailsScene,以便在其道具中提供history.location.state

const object = getSelectedRow();

<Route path="/case/:id/images" 
       render={props => (<DetailsScene{...props} title={object.title} />
       )} 
/>