-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Attempted to assign to readonly property #1813
Conversation
Can you provide the original issue for this PR? |
@ahmadfsalameh can you provide more information please? |
@adrai A few of our users got this error. When I investigated the stack trace, it led me to https://github.com/i18next/react-i18next/blob/master/src/TransWithoutContext.js#L365, where a recent pull request (#1806) introduced code that mutates the components passed in the props to add missing keys. This is an incorrect approach according to the React docs.
|
Can you create a reproducible example that triggers this error? |
The changes in this PR are wrong. I cannot reproduce the problem mentioned in this PR using @adrai I don't understand how to solve #1805 if you can't modify the components in props. No one wants to add a key to every i18n component. It's not even an array. |
@ahmadfsalameh can you help please? |
@adrai I also noticed that react does freeze props in development mode, but it's a shallow freeze, you can even run the following code, so what does this PR mention have to do with the changes in #1805? idk const obj = {
props: {
comp: {}
}
};
Object.freeze(obj.props);
obj.props.comp.key = "value";
console.log(obj.props.comp.key === "value"); |
@aiktb can you provide a new PR that reverts this...? if @ahmadfsalameh can create a new PR if he founds a better way to address his issue. |
My network environment is very bad now, and I can do it when I wake up in 8 hours |
TypeError: Attempted to assign to readonly property.
Checklist
npm run test
Checklist (for documentation change)