Dependency loop when trying to use zendeskgarden/react-forms with the scaffold?
已于 2025年4月09日 发布
I'm trying to use @zendeskgarden/react-forms, but going round in circles with dependency issues and I finally upgraded to use zendeskgarden 9.5.3. The buttons where working ok, but as soon as I try to use forms, I'm get stuck in a dependency loops.
Can anyone help? I've posted details on stackoverflow about trying to use the react-forms [Stackoverflow](https://stackoverflow.com/questions/79559874/upgrading-to-zendeskgarden-9-5-3-broken-tests-and-build-error-react-merge-ref)
This is an example of a React Component I'm creating. This was working until I introduced react-forms.
import React, { useState } from 'react';
import styled from 'styled-components';
import { mediaQuery } from '@zendeskgarden/react-theming';
import { MD } from '@zendeskgarden/react-typography';
import { DatePicker } from '@zendeskgarden/react-datepickers'
import { Input, Field } from '@zendeskgarden/react-forms'
import { Grid } from '@zendeskgarden/react-grid'
import { CustomerOrderSearchResultItemWidget } from './CustomerOrderSearchResultItemWidget';
export const CustomerOrderSearchWidget = ({searchTerm, pinnedOrder, onChangeSearchTerm, onSubmitSearchTerm, onClickToPinOrderCallBack, onClickToShowHideOrderDetailsCallback}) => {
const [Orders, setOrders] = useState([])
const [FromDate, setFromDate] = useState(Date.UTC(2024, 11, 6))
const [IsSearching, setIsSearching] = useState(false)
const handleSetOrders = (orders) => {
console.debug("CustomerOrderSearchWidget.handleSetOrders", orders)
setOrders(orders)
setIsSearching(false)
console.log("IsSearching", IsSearching)
}
const handleChangeSearchTerm = (e) => {
console.log("handleChangeSearchTerm.IsSearching", IsSearching)
setIsSearching(false)
onChangeSearchTerm(e)
}
const handleSubmitSearchTerm = (e) => {
e.preventDefault(); // Prevents page reload
console.log("handleSubmitSearchTerm", e)
setIsSearching(true)
onSubmitSearchTerm(searchTerm, handleSetOrders)
}
const handleClickToPinOrderCallBack = (order, onSetPinnedTickets) => {
onClickToPinOrderCallBack(order, onSetPinnedTickets)
}
const handleClickToShowHideOrderDetailsCallback = (order) => {
// setClicked(true);
onClickToShowHideOrderDetailsCallback(order)
}
return (
(onChangeSearchTerm === undefined || onSubmitSearchTerm === undefined || onClickToPinOrderCallBack === undefined || onClickToShowHideOrderDetailsCallback === undefined) ?
<React.Fragment><p>Something went wrong!!!</p></React.Fragment>
:
<div className="container mt-4">
<div className="input-group">
<form onSubmit={handleSubmitSearchTerm} id="form-search">
<Grid.Row justifyContent="center">
<Grid.Col>
<MD>
<Field>
<Input isCompact />
</Field>
</MD>
</Grid.Col>
</Grid.Row>
<Grid.Row justifyContent="center">
<Grid.Col>
<MD>
<Field.Label htmlFor="input-search-term">Search:</Field.Label>
<Input id="input-search-term"
placeholder="Enter search term"
minLength="3" maxLength="70"
required
isCompact
onChange={handleChangeSearchTerm} />
<input type="submit" id="btn-search-term" value="Search" />
</MD>
</Grid.Col>
</Grid.Row>
</form>
</div>
<div id="results">
{
// TODO: Use progress bar
(IsSearching === true && searchTerm !== undefined) ?
<React.Fragment>
<p>Searching...</p>
</React.Fragment> : <React.Fragment></React.Fragment>
}
{
(pinnedOrder === undefined || pinnedOrder === "") &&
<React.Fragment>
<div className="row">
<div className="col-md-4" id="pinned-order-number">
<label className="form-label">Click Attach to pin the order to this ticket</label>
</div>
</div>
</React.Fragment>
}
{
(Orders === undefined) ?
<React.Fragment><p>0 result(s).</p></React.Fragment>
:
(searchTerm && IsSearching === false) ?
<React.Fragment>
<p>{Orders.length} result(s) for {searchTerm}.</p>
</React.Fragment>
: <React.Fragment></React.Fragment>
}
{
(Orders !== undefined && IsSearching === false) ?
Orders.map((e,i) => (
<CustomerOrderSearchResultItemWidget
key={e.pkOrderID}
orderDetails={e}
onClickToPinOrderCallBack={handleClickToPinOrderCallBack}
onClickToShowHideOrderDetailsCallback={handleClickToShowHideOrderDetailsCallback}
/>
))
: <React.Fragment><p>0 result(s).</p></React.Fragment>
}
</div>
</div>
)
}
0
2
2 条评论
Greg Katechis
Hi again Dave, I think I may have figured out what was going on here. Since our React scaffold is running on v8 of Garden, the upgrade path is a bit more specific than just jumping directly into v9. Since the theme is the parent component for most (all?) of the other Garden components, the upgrade path requires that you first update theming to v9 and then everything else.
I believe that the problem is that when you went to install the forms component here is that @zendeskgarden/react-theming was on v8 and therefore, everything kinda falls apart from there. So to move forward with this, could you run `npm install @zendeskgarden/react-theming@v9`first and then try to update the rest of the components? To be clear, this is not a super well-documented thing and further to that, the fact that our scaffold is still on v8 makes this our fault, not yours, so not blaming you for missing that.
Let me know how this goes and we'll keep figuring this out if it doesn't work for you!
0
Greg Katechis
Hi Dave! Thanks for the extensive troubleshooting and repro steps that you added on the SO forums, that will definitely help us figure out what's going on here. To be honest, I'm not sure what's going on at the moment, but I'll dig into this and likely loop in our Garden product team as well to see if they can help with this. To set expectations, I may not have a response for you until next week, however I'll update you as soon as I've got some idea of what we can do here.
0
登录以发表评论。