score:0
Assuming all the routes are set up properly in your App.js, add the following changes:
Add this to your import list:
import { Link } from "react-router-dom";
In the Movies function, add the const [activeForm, setActiveForm] = useState(false); as shown below
function Movies() {
const [data, setData] = useState(null);
const [error, setError] = useState(null);
const [query, setQuery] = useState('');
const [activateModal, setActivateModal] = useState(false);
const [details, setShowDetails] = useState(false);
const [detailRequest, setDetailRequest] = useState(false);
const [activateForm, setActivateForm] = useState(false);
In the return for your function, in the div tag right under the "Content" tag, add ActivateForm={setActivateForm} as shown below.
<div style={{ background: '#4a576e', padding: 60, minHeight: 300 }}>
<SearchBox searchHandler={setQuery} />
<br />
<Row justify="center">
{ data !== null && data.length > 0 && data.map((result, index) => (
<MovieCard
ShowDetails={setShowDetails}
DetailRequest={setDetailRequest}
ActivateModal={setActivateModal}
ActivateForm={setActivateForm}
key={index}
{...result}
/>
))}
</Row>
</div>
Finally, in the Modal tag, append to the "onOk" as such, and also in your Modal footer, add the following for "onClick".
<Modal
title='Details'
centered
visible={activateModal}
onCancel={() => setActivateModal(false)}
onOk={() => setActivateForm(true)}
width={800}
footer={[
<Button key="cancel" onClick={() => setActivateModal(false)}>
Cancel
</Button>,
<Button key="schedule" onClick={() =>setActivateForm(true)}><Link to='/ScheduleForm'>Schedule</Link ></Button>
]}
>
{ detailRequest === false ?
(<MovieDetail {...details} />) :
(<Loader />)
}
</Modal>
Source: stackoverflow.com
Related Query
- Utilizing the "Ok" button in ANTd Modal in React
- Trying to flip the position of the OK and Cancel buttons inside an Antd modal using okButtonProps and cancelButtonProps for button position
- How can you show a modal in react when you press the back button browser?
- How can I pass id/class of a button present in a handlebar file into the typescript to launch a react modal when button is clicked
- How to Position a React Native Button at the bottom of my screen to work on multiple ios devices
- How to submit form component in modal dialogue using antd react component library
- How to close the modal in react native
- the title prop of a button must be a string - react native
- How to set the height of button in React Native Android
- React generated button on my form keeps refreshing the page
- Hitting Back button in React app doesn't reload the page
- Closing React Semantic UI modal with button and close icon
- React Formik bind the external button click with onSubmit function in <Formik>
- Scroll page to the nested React component on a button click
- opening a modal with the click of a button
- React antd form disable submit button
- Vertically aligning the button with the TextField in React Material-UI
- How to add a button inside a cell in the DevExtreme React Grid?
- The text of button at react native is always uppercase
- React - Material-UI Modal causing an error with the tabindex
- React JS page keeps refreshing when using the back button
- How to add floating action button on the right-bottom side of the screen using material ui in react
- React modal always take the last element of map function
- React Router V4: How to render a modal in the same screen changing only the url and then with that url, be able to rebuild the whole screen
- React + Antd + Rollup Component Library "Error: Invalid hook call. Hooks can only be called inside of the body of a function component"
- ant design - Modal value reset on "cancel" and "X" close button - API RESPONSE BASE REACT JS
- How to connect React component to the Quickbooks Button
- How to use antd divider to separate two sides of the screen in a react component?
- Ionic popover with React - How to make it sticky to the button
- How to change the color of a active button only in react native
More Query from same tag
- Redux Web Extension - Uncaught TypeError: Invalid attempt to spread non-iterable instance
- unexpected token, expected "," inside of react render() function in the return statement
- Promises inside WebWorker (react) throwing babel/webpack error
- Brand and Regular fonawesome is not rendering
- Formik Field Array field's id change when wrap with modal
- Managing states in nested components in react
- Render both text and FontAwesome icon in function return
- Value in countUp and even in typography not updating
- React condition rendering component typescript
- How can I console log a prop?
- React, Context, and Session Storage: Navigation bar updates properly when logging in but not when logging out
- TypeError: Cannot read properties of null , don't catch data- React
- Flow type error: "number [1] is incompatible with `Number` [2] in property `index`" - using React context
- Iterate over children, find last element
- How pass a array and setArray in value of provider (React, Typescript, Context)
- Adding external javascript script to React
- React router -- How to send props without query params or Redux?
- Testing Library - Test onChange not called
- npm start gives error `webpack-dev-server: not found` even if it is installed
- Using lodash to group objects by every three
- How to stop redux-form's "form" state from auto-rehydrated by redux-persit
- `yarn start` command result in `Module not found` error
- Uncaught (in promise) TypeError: _this3.setState is not a function
- Dynamic meta tags in server side using react
- React Js - Table doesn't sort names
- how to add multiple classes in preact
- 'npm start' with create-react-app not launching server on macOS
- Bug: useParams() hook initiates an error: TypeError: useContext(...) is undefined
- React TypeScript: the Key System
- Why updaing a MobX observable property doesn't work when passed as a reference