"All crop params are initially optional." When infact they are not
See original GitHub issueStated in README and in
https://github.com/DominicTobias/react-image-crop/blob/7c4ddb90a7cf33db2b55a7449f5091f769254d50/src/ReactCrop.tsx#L200-L201
but only the aspect
-prop is optional: https://github.com/DominicTobias/react-image-crop/blob/7c4ddb90a7cf33db2b55a7449f5091f769254d50/src/ReactCrop.tsx#L164-L171
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Select box not visible · Issue #149 · DominicTobias/react ...
All crop params are optional. However while you can initially omit the crop object, any subsequent change will need to be saved to...
Read more >Provide option to apply default crop if user doesn't select any
A client had requested a change where they wanted all the default crops to be automatically generated after uploading a file (rather than ......
Read more >optional parameters for immutable classes - Stack Overflow
crops up frequently in creating immutable classes that have some ... The firstName is not provided as named parameter, it's optional.
Read more >Cutting and Bordering -- IM v6 Examples - ImageMagick
The " -crop " image operator will simply cut out the part of all the images in the current sequence at the size...
Read more >Code documentation - The Python Crop Simulation Environment
One or more of these sections may be excluded when they are not appropriate for the SimulationObject that is described. The table specifying...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@DominicTobias making the prop
crop
aPartial <Crop>
object as a parameter fixes the issue of having to pass a fullCrop
into the component, but it does not fix the issue of declaring a local value as aCrop
.For example, your current definition of a
Crop
isso, if I wanted to create a local state variable to store the current crop in my component, it may look something like
This particular line, however, would throw a TypeError because my initial state value of
{ unit: '%', width: 50, aspect: 1 }
is missing the parametersheight
,x
, andy
.I believe removing the
Partial<>
from the propType and changing the type definition ofCrop
to be:may just work, though I do not know if you need any of those fields to be required specifically.
Hope this sheds some light on the issue.
This has changed in v10 (along with many breaking changes) and is no longer an issue as a complete crop always has to be passed in. Check the release notes for more info.