Version 3.1.0 is not working in React-Native when is not in debugging mode or when is generating release
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, react-native
- 领域
- mobile
调研方向
首先,在使用 serialize-javascript 3.1.0 的 React-Native release 构建中复现报告的错误,然后将其行为与 3.0.0 版本进行比较。追踪安全随机数生成错误的来源,并通过一次不进行调试的 React-Native 运行确认结果;当序列化能够在不使用调试器的情况下正常工作时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Hello, I'm using serialize-javascript in React-Native instead of JSON.stringify function. The version 3.1.0 is not working in React-Native when the debugger is off or in the release apk (because there is no debugger).
The issue is:
Error: Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11.
Reproduce:
- In React-Native project install with npm, npx or yarn the package serialize-javascript.
- Create a serialize function:
import serializeJs from 'serialize-javascript';
...
const clearArrayUndefinedValues = (array) => {
try {
if (!Array.isArray(array))
throw new Error('Invalid argument. Must be an array.');
const filteredArr = array.reduce((arr, current) => {
if (typeof current === 'object' && current !== null) {
if (Array.isArray(current))
return [...arr, clearArrayUndefinedValues(current)];
// eslint-disable-next-line no-use-before-define
return [...arr, clearObjectUndefinedValues(current)];
} else if (current !== undefined) return [...arr, current];
return arr;
}, []);
return filteredArr;
} catch (error) {
console.log(
'##\t Error log in clearArrayUndefinedValues on app/shared/utils.js ->',
error
);
return null;
}
};
const clearObjectUndefinedValues = (object) => {
try {
if (typeof object !== 'object')
throw new Error('Invalid argument. Must be an object.');
if (object === null) throw new Error('Invalid argument. Must not be null.');
const filtered = Object.keys(object).reduce((obj, key) => {
const { [key]: current } = object;
if (typeof current === 'object' && current !== null) {
if (Array.isArray(current))
return { ...obj, [key]: clearArrayUndefinedValues(current) };
return { ...obj, [key]: clearObjectUndefinedValues(current) };
} else if (current !== undefined) return { ...obj, [key]: current };
return obj;
}, {});
return filtered;
} catch (error) {
console.log(
'##\t Error log in clearObjectUndefinedValues on app/shared/utils.js ->',
error
);
return null;
}
};
export const serialize = (object) => {
try {
if (typeof object !== 'object')
throw new Error('Invalid argument. Must be an object.');
if (object === null) throw new Error('Invalid argument. Must not be null.');
if (Array.isArray(object))
return serializeJs(clearArrayUndefinedValues(object));
return serializeJs(clearObjectUndefinedValues(object));
} catch (error) {
console.log('##\t Error log in serialize on app/shared/utils.js ->', error);
return null;
}
};
- Use a serialize function in any place of your code:
import { serialize } from '../shared/utils';
...
const JSONToObject = serialize(data);
My set is:
MacOs 10.15.5
i7 2.2Ghz
16GB
Running app in simulators:
iPhone 11 os 13.5
Pixel 3 os Android API 29.
Chrome version:
83.0.4103.61 64 bits
The previous version (3.0.0) working well. There are a prevision/way to fix this to work without debugger?
- 主要语言
- JavaScript
- 星标
- 2.9k
- 派生
- 215
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 2
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
yahoo/serialize-javascript 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 72/100
yahoo/serialize-javascript#230 ·
-
难度 4/5 3-5 天 新手友好度 48/100
yahoo/serialize-javascript#229 ·
-
Ad java script 未关闭
难度 5/5 一周以上 新手友好度 20/100
yahoo/serialize-javascript#212 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 45/100
yahoo/serialize-javascript#208 · 10 条评论 · 25 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 35/100
yahoo/serialize-javascript#195 ·
查看 yahoo/serialize-javascript 的全部 Issue
相似的 Issue
-
code-quality refactoring
难度 2/5 1-3 小时 新手友好度 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
难度 2/5 1-3 小时 新手友好度 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
难度 2/5 1-3 小时 新手友好度 86/100
githubnext/gh-aw-cao#13143 ·
-
status: needs triage
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 88/100