diff --git a/snippets/Toggle.md b/snippets/Toggle.md new file mode 100644 index 000000000..f70a12fff --- /dev/null +++ b/snippets/Toggle.md @@ -0,0 +1,58 @@ +### Toggle + +Renders a toggle component. + +The `state` of the component default to `false` and bind the `handleClick` method to the component's context. +Use an object, `style`, to hold the styles for individual components and their states. +Create a method, `handleClick`, which uses `Component.prototype.setState` to change the component's `state` from toggleOn to toggleOff and vice versa. +In the `render()` method, destruct `state` and `style` to abbreviate typing, use a ` + ); + } +} +``` + +```jsx +ReactDOM.render(, document.getElementById('root')); +``` + + + + \ No newline at end of file