- Open a Terminal window.
- Install Homebrew. Be sure to press Enter and put in your computer password when asked.
- Install Node by running the following in the terminal:
brew install node
- Install Yarn by running the following in the terminal:
brew install yarn
- Install Visual Studio Code as your text editor (instead of vi)
- Congrats! Your computer is now setup for coding in React. 💻
- Navigate to the Optimizely docs and follow along the video with the next set of instructions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# myapp.rb | |
require 'sinatra' | |
get '/' do | |
'Hello world!' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# optly.rb | |
require 'singleton' | |
require 'logger' | |
require 'optimizely/optimizely_factory' | |
class Optly | |
include Singleton | |
def initialize | |
sdk_key = '<Your_SDK_Key>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func handleRequest(c *gin.Context) { | |
userObj := map[string]string{"userId": "user123"} | |
jsonString, _ := json.Marshal(userObj) | |
req, _ := http.NewRequest("POST", "http://localhost:8080/v1/activate", bytes.NewBuffer(jsonString)) | |
q := req.URL.Query() | |
q.Add("featureKey", "hello_world") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Complete code example of App.js by the end of the video */ | |
/* NOTE: Replace <Your_SDK_Key> with the SDK Key of your project below */ | |
import React from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
import { | |
createInstance, | |
OptimizelyFeature, | |
OptimizelyProvider, | |
withOptimizely |
Our SDK uses the standard node http(s) request library, which unfortunately does not automatically pull in environment-defined proxy settings. I think the current options are:
Use global-agent to set the proxy settings for the http library so that requests from http use your proxy.
npm install --save global-agent
- Before you use the Optimizely SDK:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
import { | |
createInstance, | |
OptimizelyProvider, | |
OptimizelyFeature, | |
} from '@optimizely/react-sdk' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { | |
createInstance, | |
OptimizelyProvider, | |
} from '@optimizely/react-sdk' | |
const optimizely = createInstance({ | |
sdkKey: '<Your_SDK_Key>', | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { | |
createInstance, | |
OptimizelyProvider, | |
OptimizelyFeature, | |
} from '@optimizely/react-sdk' | |
const optimizely = createInstance({ | |
sdkKey: '<Your_SDK_Key>', | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Fragment} from 'react'; | |
import { StyleSheet, View, Text } from 'react-native'; | |
import { | |
createInstance, | |
OptimizelyProvider, | |
OptimizelyFeature, | |
enums, | |
setLogger, | |
} from '@optimizely/react-sdk' |