10 examples of 'which is the return statement in react' in JavaScript

Every line of 'which is the return statement in react' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
72export function ReturnStatement(node) {
73 let expr = node.argument;
74 this.resolveType(expr);
75 let returnType = expr.resolvedType.value;
76 if (!this.returnContext) {
77 this.throw(`Invalid return context`, node);
78 }
79 let returnCtx = this.returnContext;
80 let target = this.getDeclarationName(this.returnContext);
81
82 // auto inference node return type
83 // if node doesnt return, but a return
84 // statement got found inside
85 if (returnCtx.type.value === "Void") {
86 if (INFER_FUNC_TYPE) {
87 returnCtx.isInferenced = true;
88 returnCtx.type = expr.resolvedType;
89 } else {
90 this.throw(`Inference function return types is disabled!`);
91 }
92 } else {
93 if (returnCtx.isInferenced && !this.compiled) {
94 this.throw(`Cannot inference '${target}' return type`);
95 }
96 }
97
98 let returnCtxType = returnCtx.type.value;
99 if (returnCtxType === "Void") {
100 this.throw(`Invalid return statement in '${target}'`, node);
101 }
102 if (returnCtxType !== returnType) {
103 this.throw(`'${target}' returns '${returnCtxType}' but got '${returnType}'`, node);
104 }
105 this.resolveReturnStatement(node);
106}
17module.exports = Statement.extends(KIND, function Return(expr, docs, location) {
18 Statement.apply(this, [KIND, docs, location]);
19 this.expr = expr;
20});
73export function emitReturnStatement(statement: ts.ReturnStatement, generator: LLVMGenerator): void {
74 if (statement.expression) {
75 generator.builder.createRet(generator.emitExpression(statement.expression));
76 } else {
77 generator.builder.createRetVoid();
78 }
79}
37function _default(path, scope = path.scope) {
38 const {
39 node
40 } = path;
41 const container = t.functionExpression(null, [], node.body, node.generator, node.async);
42 let callee = container;
43 let args = [];
44 (0, _helperHoistVariables.default)(path, id => scope.push({
45 id
46 }));
47 const state = {
48 foundThis: false,
49 foundArguments: false
50 };
51 path.traverse(visitor, state);
52
53 if (state.foundArguments || state.foundThis) {
54 callee = t.memberExpression(container, t.identifier("apply"));
55 args = [];
56
57 if (state.foundThis) {
58 args.push(t.thisExpression());
59 }
60
61 if (state.foundArguments) {
62 if (!state.foundThis) args.push(t.nullLiteral());
63 args.push(t.identifier("arguments"));
64 }
65 }
66
67 let call = t.callExpression(callee, args);
68 if (node.generator) call = t.yieldExpression(call, true);
69 return t.returnStatement(call);
70}
227toString() {
228 return "return " + this.argument
229}
84public visitNode(node: ts.Node) {
85 if (isElementAccessExpression(node))
86 this._checkAccess(node);
87
88 super.visitNode(node);
89}
49function _default(path, scope) {
50 if (scope === void 0) {
51 scope = path.scope;
52 }
53
54 var node = path.node;
55 var container = t().functionExpression(null, [], node.body, node.generator, node.async);
56 var callee = container;
57 var args = [];
58 (0, _helperHoistVariables().default)(path, function (id) {
59 return scope.push({
60 id: id
61 });
62 });
63 var state = {
64 foundThis: false,
65 foundArguments: false
66 };
67 path.traverse(visitor, state);
68
69 if (state.foundArguments) {
70 callee = t().memberExpression(container, t().identifier("apply"));
71 args = [];
72
73 if (state.foundThis) {
74 args.push(t().thisExpression());
75 }
76
77 if (state.foundArguments) {
78 if (!state.foundThis) args.push(t().nullLiteral());
79 args.push(t().identifier("arguments"));
80 }
81 }
82
83 var call = t().callExpression(callee, args);
84 if (node.generator) call = t().yieldExpression(call, true);
85 return t().returnStatement(call);
86}
100function hasFinalReturn(statements: t.Statement[]): boolean {
101 return t.isReturnStatement(last(statements));
102}
58visitReturnStatement(astNode) {
59 log.debug("Visiting ReturnStatement");
60 var parent = astNode.getParent();
61 var parentView = _.find(this._viewsList, ['_model',parent]);
62 //TODO create new return statement view and call render
63 return false;
64}
702export function createReturnStatement(expression) {
703 return new ReturnStatement(null, expression);
704}

Related snippets