showing results for - "switch case in jsx"
Jakob
10 Nov 2017
1renderSwitch(param) {
2  switch(param) {
3    case 'foo':
4      return 'bar';
5    default:
6      return 'foo';
7  }
8}
9
10render() {
11  return (
12    <div>
13      <div>
14          // removed for brevity
15      </div>
16      {this.renderSwitch(param)}
17      <div>
18          // removed for brevity
19      </div>
20    </div>
21  );
22}
Manuela
08 Aug 2018
1{(() => {
2    switch(...) {}
3})()}
Isaac
26 Apr 2017
1import * as actionTypes from "../store/actions/actionTypes";
2
3const initialState = {
4  counter: 0,
5  name: "Ginny",
6  tasks: ["cut onion", "drive car"],
7};
8
9const reducer = (state = initialState, action) => {
10  switch (action.type) {
11    case actionTypes.INCREMENT:
12      return {
13        ...state,
14        counter: state.counter + 1,
15      };
16    case actionTypes.DECREMENT:
17      return {
18        ...state,
19        counter: state.counter - 1,
20      };
21    case actionTypes.ADD:
22      return {
23        ...state,
24        counter: state.counter + action.value,
25      };
26    case actionTypes.ADD_TEN:
27      return {
28        ...state,
29        counter: state.counter + action.payload,
30      };
31    default:
32      return state;
33  }
34};
35
36export default reducer;
37
Lennox
13 Jan 2018
1/* Hint: Use JS IIFE (Immediately invoked function expression) in JSX */
2
3import React from 'react';
4
5import ListView from './ListView';
6import TableView from './TableView';
7
8function DataView({
9	currView,
10	data,
11	onSelect,
12	onChangeStatus,
13	viewTodo,
14	editTodo,
15	deleteTodo,
16}) {
17	return (
18		<div>
19			{(function () {
20				switch (currView) {
21					case 'table':
22						return (
23							<TableView
24								todos={data}
25								onSelect={onSelect}
26								onChangeStatus={onChangeStatus}
27								viewTodo={viewTodo}
28								editTodo={editTodo}
29								deleteTodo={deleteTodo}
30							/>
31						);
32
33					case 'list':
34						return (
35							<ListView
36								todos={data}
37								onSelect={onSelect}
38								onChangeStatus={onChangeStatus}
39								viewTodo={viewTodo}
40								editTodo={editTodo}
41								deleteTodo={deleteTodo}
42							/>
43						);
44
45					default:
46						break;
47				}
48			})()}
49		</div>
50	);
51}
52
53export default DataView;
queries leading to this page
jsx switch default not working why use switch in react react component return switchswitch component reactswitch case statement reactswitch case statement onclick react jsreact switch is not workingis switch case used in reactjswhat is react switchhow to make switch case in reactswitch case not working reatcjsswitch case in react class componentswitch case react 23react switch case in componentor in switch case reactreact js switchswitch statement reactreact switch component not workwhat does the switch statement do reactswitch button in reactswitch statement with react caroswitch case break in react jsswitch case react component renderswitch inside react renderswitch case in react functional componentreact switch 22switch statment 22react switch not workingreactjs switch what isreact switch inside renderhow to write switch case in reactreactjs onchange with switch case statementswitch case not working reactreact switch statementsreact switch examplereact component switch caseswitch in jsx returndo you still need to use switch in reactreact render by switchreact case switch not workingswitch statement react js return importreact switch between componentsreact js switch case in renderreact switch statement in renderswitch case reactjsreact return jsx eleemnt switch casereact switch functionswitch statement jsx functional componentswitch react examplehow to make switch in reactreact native switch case in renderswitch rendering reactjschange state for switch reactswitch statement in reactswitch case in react renderswitch examples reactreact switch doesn 27t turndoing operation in return section of switch statement reactreact switch uttonhow to use switch in react jsreact 3cswitch 3ecan we do a switch in react return switch case javascript reactreact switch statement componentswitch for react components reactusing switch statement in reactjsswitch case js reactwork with switch button in reacthow to render switch statement in react return functionjavascript switch case return react syntaxreact switchreact switch statement renderswitch reac jsswitch statement react jswhat is a switch in reactswitch in react for componentshow to call switch case in react jsswitch is not working in react jsswitcher in reactswitch case in reactswitch inside react componentimport switch in reactswitch statement in reactjsreact on off switchswitch statement is react jsswitch in react jsxreact switch in renderuse switch for condition reactreact switch case examplereact dom switchhow to write a switch in reactswitch case in react jsxuse switch in jsxswitch not working reactswitch in a return funcition reactreact switch case render componentswitch button reactswitch in return reactjsx switch statementswitch in reactreact switch case componenthow to use switch case in react js compponentusing switch case reactswitch statemnet in reactjsreact switch 22switch statement 22switch react not workingcase switch react function componentsuse switch case in react jsjavascript switch reactswitch case react componentreact switch statehow to use switch case in react jsswitch components reactswitch statement is not working in react componentswitch case react jsswitch button reactjsusing switch in reactswitch case react examplereact case statementswitch case in jsxuse of switch statement in react jswhat is switch in reactreact switch run functionreact render switch casereturn componenet in switch reacthow to render throuth switch case in react 3fswitch case in return reactswitch from react domwhy is switch in react not workingwhat is switch component in reactswitch case not working in reacthow to use switch button in react jsswitch react renderreact switch case true falsereturn componetn in switch case reacrtswitch case react with breakon off switch in reactswitch in jsxswitch case not working react nativeswitch case render reactcan we do a switch in react renderswitch case in javascript reactreact use switch in renderswitch to react jsis switch in react js is updatereact switch case in jsxswitch case react renderwhat does switch does in react 22switch statemanet react js 22react switch default valueswitch reactjsswitch case return jsxswitch statement react componentreact render a switchcomponent switch reactswitch button react jsreact switch case not working on returnreactjs switch not changeswitch is not working react nodejsx switch case statement not workingreact switch example 3cswitch 3e in react jsreact switch in jsxreact js switch component switch react componentreact switch case renderingswitch react rotuersyntax of switch statement react nativereact switch componentreact switch case renderassign components in react with switch caseswitch cases reactswitch in react jsswitch jsxreact switch case going to default alwaysusing switch to render reactjs switch case not getting react stateswitch case in render reactinclude switch in reactreact switch statement functional componentreactjs switch statementwhy we switch in react jsusing switch statement in jsxreact switch case with or conditionswitch case react buttonuse switch in react returnswitch render reactnot able to use switch in reactswitch in jsx reactswitch case in react js hookreact switch case in renderreact show casereact switch statement case with or operatorreact switch casejsx switch caseuse switch in react jsswitch case in react js functionswitch case in react jsreact switch within returnreact function in switch casereactjs switch componentreact return switch casehow to return switch statement in functional component in reactreact 3a return with switchswitch case reacthow to use switch condition in react jsswitch case statemtent in reacswitch case react 7c 7cswitch within react renderingswitch in react functional componentswitch loop reactswitch statement not working in reactreact render with switchreact js switch case componentreact switch i domswitch statement in react native componentreact component switchswitch case react return react 22switch react js 22switch button in react tutorialhandle switch reactswitch in react not workinguse callback with 22switch 22 reactreact switch onchangeswitch statement jsxswitch case not workin in reactswitch case syntax reactswitch react jsswitch reactswitch in react 7b 7dswitch case in react js renderwriting switch statement in reactreact js switch caseswitch en reactswitch in install in react jsusing a switch case for return render reactreact switch state renderswitch case in jsx react jsreact case switchreact switch statementis good to use switch in reactwrite switch statement in reacthow to used switch case in ract js hookhow to change value of react switcherreact switch componentsswitch case jsxhow to use switch case in react jsxhow to switch components in react get switch value in reactreactjs switch casereactjs switch case not renderingswitch return react componentjsx switchswitch button in react jsreact switch renderreact render switchswitch statement in jsxreact switch case not workingreact switch stattement in returnreact switch case defaultswitch case in jsx